You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "fgerlits (via GitHub)" <gi...@apache.org> on 2023/06/07 10:55:43 UTC

[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1576: MINIFICPP-2121 - Use std::atomic_flag instead of semaphore

fgerlits commented on code in PR #1576:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1576#discussion_r1221378728


##########
minifi_main/MiNiFiMain.cpp:
##########
@@ -91,27 +90,26 @@ static sem_t *process_running;
 
 #ifdef WIN32
 BOOL WINAPI consoleSignalHandler(DWORD signal) {
-  if (!process_running) { exit(0); return TRUE; }
+  if (!process_running.test()) { exit(0); return TRUE; }
   if (signal == CTRL_C_EVENT || signal == CTRL_BREAK_EVENT) {
-    int ret = ETIMEDOUT;
-    while (ret == ETIMEDOUT) {
-      if (flow_controller_running) { sem_post(flow_controller_running); }
-      const struct timespec timeout_100ms { .tv_sec = 0, .tv_nsec = 100000000};
-      ret = sem_timedwait(process_running, &timeout_100ms);
-    }
+    flow_controller_running.clear();
+    flow_controller_running.notify_all();
+    process_running.wait(false);

Review Comment:
   should this be `wait(true)`?  from the docs, it looks to me that `wait(x)` waits for the flag to be _not_ x, and we want to wait for `process_running` to become `false` (ie, not `true`)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org