diff --git a/flight/uavobjects/eventdispatcher.c b/flight/uavobjects/eventdispatcher.c index 03e0c646c..586a68cc6 100644 --- a/flight/uavobjects/eventdispatcher.c +++ b/flight/uavobjects/eventdispatcher.c @@ -287,11 +287,16 @@ static void eventTask() EventCallbackInfo evInfo; // Wait for queue message + int limit = MAX_QUEUE_SIZE; while (xQueueReceive(mQueue, &evInfo, 0) == pdTRUE) { - // Invoke callback, if one + // Invoke callback, if any if (evInfo.cb != 0) { evInfo.cb(&evInfo.ev); // the function is expected to copy the event information } + // limit loop to max queue size to slightly reduce the impact of recursive events + if (!--limit) { + break; + } } // Process periodic updates