Skip to content

Commit

Permalink
dbCa CP link updates set PUTF/RPRO
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavidsaver committed Dec 28, 2024
1 parent 1699489 commit 053b924
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 39 deletions.
56 changes: 18 additions & 38 deletions modules/database/src/ioc/db/dbCa.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ static int dbca_chan_count;
* During link modification or IOC shutdown the pca->plink pointer (guarded by caLink.lock)
* is used as a flag to indicate that a link is no longer active.
*
* References to the struct caLink are owned by the dbCaTask, and any scanOnceCallback()
* which is in progress.
* References to the struct caLink are owned by the dbCaTask.
*
* The libca and scanOnceCallback callbacks take no action if pca->plink==NULL.
* The libca callbacks take no action if pca->plink==NULL.
*
* dbCaPutLinkCallback causes an additional complication because
* when dbCaRemoveLink is called the callback may not have occured.
Expand Down Expand Up @@ -788,38 +787,6 @@ static long doLocked(struct link *plink, dbLinkUserCallback rtn, void *priv)
return status;
}

static void scanComplete(void *raw, dbCommon *prec)
{
caLink *pca = raw;
epicsMutexMustLock(pca->lock);
if(!pca->plink) {
/* IOC shutdown or link re-targeted. Do nothing. */
} else if(pca->scanningOnce==0) {
errlogPrintf("dbCa.c complete callback w/ scanningOnce==0\n");
} else if(--pca->scanningOnce){
/* another scan is queued */
if(scanOnceCallback(prec, scanComplete, raw)) {
errlogPrintf("dbCa.c failed to re-queue scanOnce\n");
} else
caLinkInc(pca);
}
epicsMutexUnlock(pca->lock);
caLinkDec(pca);
}

/* must be called with pca->lock held */
static void scanLinkOnce(dbCommon *prec, caLink *pca) {
if(pca->scanningOnce==0) {
if(scanOnceCallback(prec, scanComplete, pca)) {
errlogPrintf("dbCa.c failed to queue scanOnce\n");
} else
caLinkInc(pca);
}
if(pca->scanningOnce<5)
pca->scanningOnce++;
/* else too many scans queued */
}

static lset dbCa_lset = {
0, 1, /* not Constant, Volatile */
NULL, dbCaRemoveLink,
Expand Down Expand Up @@ -856,7 +823,9 @@ static void connectionCallback(struct connection_handler_args arg)
if (precord &&
((ppv_link->pvlMask & pvlOptCP) ||
((ppv_link->pvlMask & pvlOptCPP) && precord->scan == 0)))
scanLinkOnce(precord, pca);
{
link_action |= CA_DBPROCESS;
}
goto done;
}
pca->hasReadAccess = ca_read_access(arg.chid);
Expand Down Expand Up @@ -988,7 +957,9 @@ static void eventCallback(struct event_handler_args arg)

if ((ppv_link->pvlMask & pvlOptCP) ||
((ppv_link->pvlMask & pvlOptCPP) && precord->scan == 0))
scanLinkOnce(precord, pca);
{
addAction(pca, CA_DBPROCESS);
}
}
done:
epicsMutexUnlock(pca->lock);
Expand Down Expand Up @@ -1061,7 +1032,9 @@ static void accessRightsCallback(struct access_rights_handler_args arg)
if (precord &&
((ppv_link->pvlMask & pvlOptCP) ||
((ppv_link->pvlMask & pvlOptCPP) && precord->scan == 0)))
scanLinkOnce(precord, pca);
{
addAction(pca, CA_DBPROCESS);
}
done:
epicsMutexUnlock(pca->lock);
}
Expand Down Expand Up @@ -1273,6 +1246,13 @@ static void dbCaTask(void *arg)
printLinks(pca);
}
}
if (link_action & CA_DBPROCESS) {
dbCommon *prec;
epicsMutexMustLock(pca->lock);
prec = pca->plink->precord;
epicsMutexUnlock(pca->lock);
db_process(prec);
}
}
SEVCHK(ca_flush_io(), "dbCaTask");
}
Expand Down
1 change: 1 addition & 0 deletions modules/database/src/ioc/db/dbCaPvt.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define CA_MONITOR_STRING 0x20
#define CA_GET_ATTRIBUTES 0x40
#define CA_SYNC 0x1000
#define CA_DBPROCESS 0x2000
/* write type */
#define CA_PUT 0x1
#define CA_PUT_CALLBACK 0x2
Expand Down
14 changes: 14 additions & 0 deletions modules/database/src/ioc/db/db_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,3 +1029,17 @@ int db_put_process(processNotify *ppn, notifyPutType type,
ppn->status = notifyError;
return 1;
}

void db_process(struct dbCommon *prec)
{
if (prec->pact) {
if (dbAccessDebugPUTF && prec->tpro)
printf("%s: dbPutField to Active '%s', setting RPRO=1\n",
epicsThreadGetNameSelf(), prec->name);
prec->rpro = TRUE;
} else {
/* indicate that dbPutField called dbProcess */
prec->putf = TRUE;
(void)dbProcess(prec);
}
}
6 changes: 5 additions & 1 deletion modules/database/src/ioc/db/db_access_routines.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ extern "C" {

#include "dbCoreAPI.h"

struct dbCommon;

DBCORE_API extern struct dbBase *pdbbase;
DBCORE_API extern volatile int interruptAccept;

Expand All @@ -36,7 +38,9 @@ DBCORE_API int dbChannel_put(struct dbChannel *chan, int src_type,
const void *psrc, long no_elements);
DBCORE_API int dbChannel_get_count(struct dbChannel *chan,
int buffer_type, void *pbuffer, long *nRequest, void *pfl);

#ifdef EPICS_DBCA_PRIVATE_API
DBCORE_API void db_process(struct dbCommon *prec);
#endif

#ifdef __cplusplus
}
Expand Down

0 comments on commit 053b924

Please sign in to comment.