Skip to content

Commit

Permalink
avoid blocking the notify thread, fixup event on win32
Browse files Browse the repository at this point in the history
The prior io thread had a couple of issues; consuming from the
inotify fd is actually a blocking operation, so we need to add
a check to our loop condition.

Fixup how we interpret the result of a wait on a win32 event,
so that we don't falsely believe that is has been satisfied
in the timeout case (doh!)
  • Loading branch information
wez committed Aug 20, 2015
1 parent 45f0fd4 commit 29f2df5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions root.c
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,9 @@ static void notify_thread(w_root_t *root)
if (w_ht_size(root->pending_uniq) >= WATCHMAN_BATCH_LIMIT) {
break;
}
if (!wait_for_notify(root, 0)) {
break;
}
}
w_event_set(root->have_pending_evt);
}
Expand Down Expand Up @@ -1782,7 +1785,9 @@ static void io_thread(w_root_t *root)

// Wait for the notify thread to give us pending items, or for
// the settle period to expire
w_log(W_LOG_DBG, "poll_events timeout=%dms\n", timeoutms);
w_poll_events(&pevt, 1, timeoutms);
w_log(W_LOG_DBG, " ... wake up\n");
if (!w_event_test_and_clear(root->have_pending_evt)) {
// No new pending items were given to us, so consider that
// we may not be settled.
Expand Down
2 changes: 1 addition & 1 deletion stream_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void w_event_destroy(w_evt_t evt) {
}

bool w_event_test_and_clear(w_evt_t evt) {
bool was_set = WaitForSingleObject(evt, 0);
bool was_set = WaitForSingleObject(evt, 0) == WAIT_OBJECT_0;
ResetEvent(evt);
return was_set;
}
Expand Down

0 comments on commit 29f2df5

Please sign in to comment.