send DBE_PROPERTY events only if property field actually changed

This commit is contained in:
2024-08-30 11:58:12 +02:00
committed by Andrew Johnson
parent 1f8851a5dc
commit faac1df1c6
2 changed files with 23 additions and 7 deletions

View File

@ -22,6 +22,11 @@ should also be read to understand what has changed since earlier releases:
## Changes made on the 7.0 branch since 7.0.8.1 ## Changes made on the 7.0 branch since 7.0.8.1
### DBE_PROPERTY event rate changed
Updating property fields now only post DBE_PROPERTY events if the
field actually changed.
### Allow users to delete previously created records from the database ### Allow users to delete previously created records from the database
From this release, record instances and aliases that have already been loaded From this release, record instances and aliases that have already been loaded

View File

@ -1325,6 +1325,7 @@ long dbPut(DBADDR *paddr, short dbrType,
long status = 0; long status = 0;
dbFldDes *pfldDes; dbFldDes *pfldDes;
int isValueField; int isValueField;
int propertyUpdate = paddr->pfldDes->prop && precord->mlis.count;
if (special == SPC_ATTRIBUTE) if (special == SPC_ATTRIBUTE)
return S_db_noMod; return S_db_noMod;
@ -1369,8 +1370,22 @@ long dbPut(DBADDR *paddr, short dbrType,
if (nRequest < 1) { if (nRequest < 1) {
recGblSetSevr(precord, LINK_ALARM, INVALID_ALARM); recGblSetSevr(precord, LINK_ALARM, INVALID_ALARM);
} else { } else {
status = dbFastPutConvertRoutine[dbrType][field_type](pbuffer, if (propertyUpdate && paddr->field_size <= MAX_STRING_SIZE) {
paddr->pfield, paddr); char propBuffer[MAX_STRING_SIZE];
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; nRequest = 1;
} }
} }
@ -1391,11 +1406,7 @@ long dbPut(DBADDR *paddr, short dbrType,
if (precord->mlis.count && if (precord->mlis.count &&
!(isValueField && pfldDes->process_passive)) !(isValueField && pfldDes->process_passive))
db_post_events(precord, pfieldsave, DBE_VALUE | DBE_LOG); db_post_events(precord, pfieldsave, DBE_VALUE | DBE_LOG);
/* If this field is a property (metadata) field, if (propertyUpdate)
* then post a property change event (even if the field
* didn't change).
*/
if (precord->mlis.count && pfldDes->prop)
db_post_events(precord, NULL, DBE_PROPERTY); db_post_events(precord, NULL, DBE_PROPERTY);
done: done:
paddr->pfield = pfieldsave; paddr->pfield = pfieldsave;