From e07b2e812d2e3dc812104f0e64baf6ca0744131d Mon Sep 17 00:00:00 2001 From: PengZheng Date: Wed, 12 Jun 2024 17:14:49 +0800 Subject: [PATCH] gh-215: Remove all remaining scheduled events for an inactive dispatcher. --- libs/framework/src/framework.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c index e3b0431df..0c73f8afb 100644 --- a/libs/framework/src/framework.c +++ b/libs/framework/src/framework.c @@ -1383,7 +1383,7 @@ static void celix_framework_processScheduledEvents(celix_framework_t* fw) { celixThreadMutex_lock(&fw->dispatcher.mutex); CELIX_LONG_HASH_MAP_ITERATE(fw->dispatcher.scheduledEvents, entry) { celix_scheduled_event_t* visit = entry.value.ptrValue; - if (celix_scheduledEvent_isMarkedForRemoval(visit)) { + if (!fw->dispatcher.active || celix_scheduledEvent_isMarkedForRemoval(visit)) { removeEvent = visit; celix_longHashMap_remove(fw->dispatcher.scheduledEvents, celix_scheduledEvent_getId(visit)); break; @@ -1536,6 +1536,7 @@ static void *fw_eventDispatcher(void *fw) { celixThreadMutex_unlock(&framework->dispatcher.mutex); while (needExtraRun) { fw_handleEvents(framework); + celix_framework_processScheduledEvents(framework); celixThreadMutex_lock(&framework->dispatcher.mutex); needExtraRun = celix_framework_eventQueueSize(fw) > 0; celixThreadMutex_unlock(&framework->dispatcher.mutex);