thibaudgg/rb-fsevent — pull request #32 by Maher4Ever (2012-04-03 22:07:25+00:00)
Title: 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.

As you know, testing synchronization problems with unit tests is impossible... because these problems only occur when a special combination of events happen _simultaneously_. That's why there is no spec for this problem.