Commit 76201cc1 authored by Franksen, Benjamin's avatar Franksen, Benjamin
Browse files

devLowCAL: avoid conflicting lowcal_read calls


This could happen for client rw variables with two records for input and
output, when the output record uses bumpless reboot to read back the last
setpoint from the hardware and the input record starts processing before the
output record has finished.

To avoid the problem, set the sibling input record's PACT field during
initialization if the output record initiates bumpless reboot. In the
special client/rw  callback, the input record's PACT is reset and if the
LCNT is positive, the failed processing (due to PACT set) is tried again.
parent dd7f01e2
......@@ -551,6 +551,9 @@ static long devlc_init_record(dbCommon *prec, int rflags, struct link *plink)
/* sibling output record has already allocated reboot callback */
callbackGetUser(precs, pread);
/* do not assign our own priority here */
if (precs->out) {
prec->pact = TRUE; /* avoid simultaneous lowcal_read */
}
}
precs->in = prec;
}
......@@ -576,6 +579,9 @@ static long devlc_init_record(dbCommon *prec, int rflags, struct link *plink)
} else {
/* sibling input record has already allocated reboot callback */
callbackGetUser(precs, pread);
if (precs->in) {
precs->in->pact = TRUE; /* avoid simultaneous lowcal_read */
}
}
/* Prepare for bumpless reboot */
prec->pini = FALSE;
......@@ -714,12 +720,13 @@ static void devlc_client_rw_callback(CALLBACK *pcallback)
in the input record */
dbScanLock(pin);
callbackSetPriority(pin->prio, pcallback);
if (!pin->pact)
errlogPrintf("INTERNAL ERROR: sibling read record not active "
"in devlc_client_rw_callback (record %s).\n", pin->name);
pin->pact = FALSE;
/* check if input record has tried to read in the meantime */
if (pin->pact) {
/* instead of processing we act as if this were the first
processing, so reset pact and call devlc_read */
pin->pact = FALSE;
devlc_read(pin);
if (pin->lcnt) {
dbProcess(pin); /* do it again, this time without PACT */
}
dbScanUnlock(pin);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment