Please sign in to comment.
Fix a synchronisation bug
The run method will almost always be called inside a thread. This commit fixes a synchronisation problem between the run and stop methods by explicitly opening a pipe on the beginning of the run method. The source of the problem is the fact that when someone stops the watcher, the @path would become nil and calling the private method pipe would create a new pipe. A sitiuation where this could be a problem is when the run method is waiting on changes (blocking on select), note here that @running does not matter anymore, the code is blocking on select! Stoping the watcher and firing an event at the same time would unblock the run method and getting the results in the old code would have created a new pipe and blocked on readline.
- Loading branch information...