From 360e58abdea530eb9260dd8baa9bc7fa0f906191 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Fri, 28 Jun 2013 19:03:25 +0200 Subject: [PATCH] eventdispatcher, limit event callback count fired in one go --- flight/uavobjects/eventdispatcher.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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