File tree Expand file tree Collapse file tree 1 file changed +17
-10
lines changed
Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -456,23 +456,30 @@ void handleNotification(NotifInfo *notif)
456456void async_cb_handler (uv_async_t *handle)
457457// ===================================================================
458458{
459- NotifInfo * notif;
460-
461- mutex::scoped_lock sl (zqueue_mutex);
462-
459+ NotifInfo* notif;
460+ std::list<NotifInfo*> notifications;
461+ // consume all the queued notifications
462+ zqueue_mutex. lock ();
463463 while (!zqueue.empty ()) {
464464 notif = zqueue.front ();
465+ notifications.push_back (notif);
466+ zqueue.pop ();
467+ }
468+ // unlock the mutex so that notification handlers are safe to invoke more notifications
469+ zqueue_mutex.unlock ();
470+ // process notifications
471+ std::list<NotifInfo*>::const_iterator it;
472+ for (it = notifications.begin (); it != notifications.end (); ++it) {
465473#if OPENZWAVE_SECURITY != 1
466- if (notif ->homeid == 0 ) {
467- handleControllerCommand (notif );
474+ if (*it ->homeid == 0 ) {
475+ handleControllerCommand (*it );
468476 } else {
469- handleNotification (notif );
477+ handleNotification (*it );
470478 }
471479#else
472- handleNotification (notif );
480+ handleNotification (*it );
473481#endif
474- delete notif;
475- zqueue.pop ();
482+ delete *it;
476483 }
477484}
478485
You can’t perform that action at this time.
0 commit comments