From e33728362d5db76feb1f7ee0ada73d8abb5bf69a Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Mon, 20 Feb 2023 15:16:04 +0100 Subject: [PATCH] Get back calcout record link fix This reverts part of commit 55536a13db827ae23289d7b5907f44fe63be114d. --- modules/database/src/ioc/db/dbAccess.c | 68 +++++++++++++------ .../database/src/std/dev/devAiSoftCallback.c | 2 +- .../database/src/std/dev/devBiSoftCallback.c | 2 +- .../src/std/dev/devI64inSoftCallback.c | 2 +- .../database/src/std/dev/devLiSoftCallback.c | 2 +- .../src/std/dev/devMbbiDirectSoftCallback.c | 2 +- .../src/std/dev/devMbbiSoftCallback.c | 2 +- .../database/src/std/dev/devSiSoftCallback.c | 2 +- 8 files changed, 55 insertions(+), 27 deletions(-) diff --git a/modules/database/src/ioc/db/dbAccess.c b/modules/database/src/ioc/db/dbAccess.c index 8fcdab8a7..f3af9a4a3 100644 --- a/modules/database/src/ioc/db/dbAccess.c +++ b/modules/database/src/ioc/db/dbAccess.c @@ -1177,7 +1177,44 @@ static long dbPutFieldLink(DBADDR *paddr, if (!status) status = dbSetLink(plink, &link_info, new_devsup); - if (!status && special) status = dbPutSpecial(paddr, 1); + if (status) { + if (isDevLink) { + precord->dset = NULL; + precord->pact = TRUE; + } + goto postScanEvent; + } + + /* We need to initialize any links with a link support layer, i.e. + * any CONSTANT, JSON_LINK, or PV_LINK types. However for a PV_LINK + * when isDevLink is set (i.e. this is the record's INP or OUT link) + * we must wait until after calling dsxt->add_record(). This allows + * the Async Soft Channel input supports to change it to a PN_LINK. + * For other cases we initialize the link before the second call to + * dbPutSpecial() because some record types such as calcout need to + * be able to call link support methods from prset->special(). + */ + + switch (plink->type) { /* New type */ + case PV_LINK: + if (isDevLink) + break; + /* else fall through */ + case CONSTANT: + case JSON_LINK: + dbAddLink(&locker, plink, pfldDes->field_type, chan); + chan = NULL; /* we used it, don't clean it up */ + } + + if (special) status = dbPutSpecial(paddr, 1); + + if (!status && isDevLink) { + precord->dpvt = NULL; + precord->dset = new_dset; + precord->pact = FALSE; + + status = new_dsxt->add_record(precord); + } if (status) { if (isDevLink) { @@ -1187,29 +1224,21 @@ static long dbPutFieldLink(DBADDR *paddr, goto postScanEvent; } - if (isDevLink) { - precord->dpvt = NULL; - precord->dset = new_dset; - precord->pact = FALSE; - - status = new_dsxt->add_record(precord); - if (status) { - precord->dset = NULL; - precord->pact = TRUE; - goto postScanEvent; - } - } - switch (plink->type) { /* New link type */ - case PV_LINK: case CONSTANT: + case CA_LINK: + case DB_LINK: + case PN_LINK: case JSON_LINK: - dbAddLink(&locker, plink, pfldDes->field_type, chan); - chan = NULL; /* don't clean it up */ break; - case DB_LINK: - case CA_LINK: + case PV_LINK: + if (isDevLink) { + dbAddLink(&locker, plink, pfldDes->field_type, chan); + chan = NULL; /* we used it, don't clean it up */ + } + break; + case MACRO_LINK: break; /* should never get here */ @@ -1218,7 +1247,6 @@ static long dbPutFieldLink(DBADDR *paddr, status = S_db_badHWaddr; goto postScanEvent; } - break; } db_post_events(precord, plink, DBE_VALUE | DBE_LOG); diff --git a/modules/database/src/std/dev/devAiSoftCallback.c b/modules/database/src/std/dev/devAiSoftCallback.c index a7ed167db..db13fbbed 100644 --- a/modules/database/src/std/dev/devAiSoftCallback.c +++ b/modules/database/src/std/dev/devAiSoftCallback.c @@ -81,7 +81,7 @@ static long add_record(dbCommon *pcommon) devPvt *pdevPvt; processNotify *ppn; - if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + if (plink->type == CONSTANT) return 0; if (plink->type != PV_LINK) { diff --git a/modules/database/src/std/dev/devBiSoftCallback.c b/modules/database/src/std/dev/devBiSoftCallback.c index 3bd38f8f2..4fcbc464b 100644 --- a/modules/database/src/std/dev/devBiSoftCallback.c +++ b/modules/database/src/std/dev/devBiSoftCallback.c @@ -79,7 +79,7 @@ static long add_record(dbCommon *pcommon) devPvt *pdevPvt; processNotify *ppn; - if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + if (plink->type == CONSTANT) return 0; if (plink->type != PV_LINK) { diff --git a/modules/database/src/std/dev/devI64inSoftCallback.c b/modules/database/src/std/dev/devI64inSoftCallback.c index 0ccdfcc18..4af1a885e 100644 --- a/modules/database/src/std/dev/devI64inSoftCallback.c +++ b/modules/database/src/std/dev/devI64inSoftCallback.c @@ -79,7 +79,7 @@ static long add_record(dbCommon *pcommon) devPvt *pdevPvt; processNotify *ppn; - if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + if (plink->type == CONSTANT) return 0; if (plink->type != PV_LINK) { diff --git a/modules/database/src/std/dev/devLiSoftCallback.c b/modules/database/src/std/dev/devLiSoftCallback.c index 058abd93a..7c7c5d86b 100644 --- a/modules/database/src/std/dev/devLiSoftCallback.c +++ b/modules/database/src/std/dev/devLiSoftCallback.c @@ -79,7 +79,7 @@ static long add_record(dbCommon *pcommon) devPvt *pdevPvt; processNotify *ppn; - if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + if (plink->type == CONSTANT) return 0; if (plink->type != PV_LINK) { diff --git a/modules/database/src/std/dev/devMbbiDirectSoftCallback.c b/modules/database/src/std/dev/devMbbiDirectSoftCallback.c index e2269d25e..c46e90bb4 100644 --- a/modules/database/src/std/dev/devMbbiDirectSoftCallback.c +++ b/modules/database/src/std/dev/devMbbiDirectSoftCallback.c @@ -79,7 +79,7 @@ static long add_record(dbCommon *pcommon) devPvt *pdevPvt; processNotify *ppn; - if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + if (plink->type == CONSTANT) return 0; if (plink->type != PV_LINK) { diff --git a/modules/database/src/std/dev/devMbbiSoftCallback.c b/modules/database/src/std/dev/devMbbiSoftCallback.c index ae97fc70a..4afcb3e3e 100644 --- a/modules/database/src/std/dev/devMbbiSoftCallback.c +++ b/modules/database/src/std/dev/devMbbiSoftCallback.c @@ -79,7 +79,7 @@ static long add_record(dbCommon *pcommon) devPvt *pdevPvt; processNotify *ppn; - if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + if (plink->type == CONSTANT) return 0; if (plink->type != PV_LINK) { diff --git a/modules/database/src/std/dev/devSiSoftCallback.c b/modules/database/src/std/dev/devSiSoftCallback.c index f52d595c1..d357a49fe 100644 --- a/modules/database/src/std/dev/devSiSoftCallback.c +++ b/modules/database/src/std/dev/devSiSoftCallback.c @@ -81,7 +81,7 @@ static long add_record(dbCommon *pcommon) devPvt *pdevPvt; processNotify *ppn; - if (dbLinkIsDefined(plink) && dbLinkIsConstant(plink)) + if (plink->type == CONSTANT) return 0; if (plink->type != PV_LINK) {