Skip to content

Commit

Permalink
Fix random thread hanging due to incorrect pthread_cond_wait usage (#290
Browse files Browse the repository at this point in the history
)

* Fix random thread hanging due to incorrect pthread_cond_wait usage

* Update rawfsevents.c
  • Loading branch information
RomanHotsiy authored and paulmillr committed Oct 11, 2019
1 parent d5cc566 commit f95c1ac
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/rawfsevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ void fse_watch(const char *path, fse_event_handler_t handler, void *context, fse
pthread_mutex_lock(&fsevents.lock);
if (!fsevents.loop) {
pthread_create(&fsevents.thread, NULL, fse_run_loop, NULL);
while (!fsevents.loop) {
pthread_cond_wait(&fsevents.init, &fsevents.lock);
}
pthread_mutex_unlock(&fsevents.lock);
pthread_cond_wait(&fsevents.init, &fsevents.lock);
}

strncpy(watcher->path, path, PATH_MAX);
Expand Down

0 comments on commit f95c1ac

Please sign in to comment.