From 06bc23f38801371c60e97b8f71ee7ce7719160fd Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Fri, 30 Aug 2024 11:58:12 +0200 Subject: [PATCH] send DBE_PROPERTY events only if property field actually changed --- modules/database/src/ioc/db/dbAccess.c | 27 +++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/modules/database/src/ioc/db/dbAccess.c b/modules/database/src/ioc/db/dbAccess.c index 21f5f0b64a..2a943f9314 100644 --- a/modules/database/src/ioc/db/dbAccess.c +++ b/modules/database/src/ioc/db/dbAccess.c @@ -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; @@ -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; } } @@ -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;