From e8d8222d8634a20f4d1355e5ccfce87319572fb2 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 7 Jul 2017 11:49:13 +0100 Subject: [PATCH] Special-handle DEVICE_ID_NOTIFY_ONE --- libs/core/linux.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/core/linux.cpp b/libs/core/linux.cpp index bf6005c4..963bc0f3 100644 --- a/libs/core/linux.cpp +++ b/libs/core/linux.cpp @@ -222,10 +222,18 @@ static void *evtDispatcher(void *dummy) { eventTail = NULL; for (auto thr = allThreads; thr; thr = thr->next) { - if (thr->waitSource == ev->source && - (thr->waitValue == ev->value || thr->waitValue == DEVICE_EVT_ANY)) { + if (thr->waitSource == 0) + continue; + if (thr->waitValue != ev->value && thr->waitValue != DEVICE_EVT_ANY) + continue; + if (thr->waitSource == ev->source) { thr->waitSource = 0; // once! pthread_cond_broadcast(&thr->waitCond); + } else if (thr->waitSource == DEVICE_ID_NOTIFY && + ev->source == DEVICE_ID_NOTIFY_ONE) { + thr->waitSource = 0; // once! + pthread_cond_broadcast(&thr->waitCond); + break; // do not wake up any other threads } }