ioc: group avoid post() empty events

first update should never be empty, so warn if it somehow is.
This commit is contained in:
Michael Davidsaver
2023-10-16 11:05:23 -07:00
parent 88b67527f1
commit ff3e293a37
+11 -3
View File
@@ -209,19 +209,27 @@ void subscriptionPost(GroupSourceSubscriptionCtx *pGroupCtx)
// Make sure that the initial subscription update has occurred on all channels before replying
// As we make two initial updates when opening a new subscription, for each field,
// we need all updates for all fields to have completed before continuing
bool first = false;
if (!pGroupCtx->eventsPrimed) {
for (auto& fieldCtx: pGroupCtx->fieldSubscriptionContexts) {
if (!fieldCtx.hadValueEvent || !fieldCtx.hadPropertyEvent) {
return;
}
}
pGroupCtx->eventsPrimed = true;
pGroupCtx->eventsPrimed = first = true;
}
log_debug_printf(_logname, "%s : %s\n", __func__, pGroupCtx->group.name.c_str());
auto& currentValue = pGroupCtx->currentValue;
bool empty(!currentValue.isMarked(false, true));
Level lvl = first && empty ? Level::Warn : Level::Debug;
log_printf(_logname, lvl, "%s%s%s : %s\n", __func__,
first ? " first" : "", empty ? " empty" : "",
pGroupCtx->group.name.c_str());
if(empty && !first)
return;
// If events have been primed then return the value to the subscriber,
// and unmark all accumulated changes
pGroupCtx->subscriptionControl->post(currentValue.clone());