Skip to content

Commit

Permalink
send DBE_PROPERTY events only if property field actually changed
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-zimoch committed Aug 30, 2024
1 parent 052a0c7 commit 06bc23f
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions modules/database/src/ioc/db/dbAccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,7 @@ long dbPut(DBADDR *paddr, short dbrType,
long status = 0;
dbFldDes *pfldDes;
int isValueField;
int propertyUpdate = 0;

if (special == SPC_ATTRIBUTE)
return S_db_noMod;
Expand Down Expand Up @@ -1369,8 +1370,23 @@ long dbPut(DBADDR *paddr, short dbrType,
if (nRequest < 1) {
recGblSetSevr(precord, LINK_ALARM, INVALID_ALARM);
} else {
status = dbFastPutConvertRoutine[dbrType][field_type](pbuffer,
paddr->pfield, paddr);
propertyUpdate = paddr->pfldDes->prop && precord->mlis.count;
if (propertyUpdate && paddr->field_size <= sizeof(epicsAny)) {
epicsAny propBuffer;
status = dbFastPutConvertRoutine[dbrType][field_type](pbuffer,
&propBuffer, paddr);
if (!status) {
if (memcmp(paddr->pfield, &propBuffer, paddr->field_size) != 0) {
memcpy(paddr->pfield, &propBuffer, paddr->field_size);
} else {
/* suppress DBE_PROPERTY event if property did not change */
propertyUpdate = 0;
}
}
} else {
status = dbFastPutConvertRoutine[dbrType][field_type](pbuffer,
paddr->pfield, paddr);
}
nRequest = 1;
}
}
Expand All @@ -1391,12 +1407,9 @@ long dbPut(DBADDR *paddr, short dbrType,
if (precord->mlis.count &&
!(isValueField && pfldDes->process_passive))
db_post_events(precord, pfieldsave, DBE_VALUE | DBE_LOG);
/* If this field is a property (metadata) field,
* then post a property change event (even if the field
* didn't change).
*/
if (precord->mlis.count && pfldDes->prop)
if (propertyUpdate) {
db_post_events(precord, NULL, DBE_PROPERTY);
}
done:
paddr->pfield = pfieldsave;
return status;
Expand Down

0 comments on commit 06bc23f

Please sign in to comment.