howeyc / fsnotify

File system notification for Go
BSD 3-Clause "New" or "Revised" License
1.99k stars 252 forks source link

Fix deadlock on BSD #77

Closed cespare closed 10 years ago

cespare commented 10 years ago

I'm using fsnotify for a project where I set up recursive watches using the usual directory walking song and dance. I noticed that on Mac OS fsnotify would quickly get into a bad state where I'd stop receiving any events.

It turned out that fsnotify was deadlocking because mutexes weren't always properly released.

The removeWatch routine could return without releasing the lock on w.bufmut. This change unlocks the mutex before checking for errors.

howeyc commented 10 years ago

Thanks!