From b6626e4f60697d577097e335ce79e1ecbce3fee6 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 22 Jan 2023 13:28:10 -0800 Subject: [PATCH] dbEvent: try to detect possible "stall" event_read() should not return if the last callback was delivered with eventsRemaining!=0 --- modules/database/src/ioc/db/dbEvent.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/database/src/ioc/db/dbEvent.c b/modules/database/src/ioc/db/dbEvent.c index 4fd4fde06..d5c930dfc 100644 --- a/modules/database/src/ioc/db/dbEvent.c +++ b/modules/database/src/ioc/db/dbEvent.c @@ -76,6 +76,7 @@ struct event_que { unsigned short quota; /* the number of assigned entries*/ unsigned short nDuplicates; /* N events duplicated on this q */ unsigned short nCanceled; /* the number of canceled entries */ + unsigned possibleStall; }; struct event_user { @@ -934,6 +935,7 @@ void db_post_single_event (dbEventSubscription event) static int event_read ( struct event_que *ev_que ) { db_field_log *pfl; + int notifiedRemaining = 0; void ( *user_sub ) ( void *user_arg, struct dbChannel *chan, int eventsRemaining, db_field_log *pfl ); @@ -1012,6 +1014,7 @@ static int event_read ( struct event_que *ev_que ) /* Issue user callback */ ( *user_sub ) ( pevent->user_arg, pevent->chan, eventsRemaining, pfl ); + notifiedRemaining = eventsRemaining; } LOCKEVQUE (ev_que); @@ -1038,6 +1041,11 @@ static int event_read ( struct event_que *ev_que ) db_delete_field_log(pfl); } + if(notifiedRemaining && !ev_que->possibleStall) { + ev_que->possibleStall = 1; + errlogPrintf(ERL_WARNING " dbEvent possible queue stall\n"); + } + UNLOCKEVQUE (ev_que); return DB_EVENT_OK;