Descriptioninotify: Fix readEntry hanging and Add/RemoveWatch failing when watched directories deleted and re-created.
If a watched directory is deleted and recreated, and watched again, many of the events sent back are hosed.
- The event.Name is incomplete, missing the path of the watched directory (you get /a.txt or "")
- RemoveWatch thereafter fails with message: invalid argument
- Close() doesn't really close, and readEvents hangs forever on syscall.Read(...)
Note that the readEvents() hanging was always there, irrespective of the steps to produce issues with Add/RemoveWatch.
Fix involves:
- use Select to ensure there's data to read, else syscall.Read(...) will keep on waiting, even though intent to close was sent.
- Let Close() wait till completely closed (use sync channel with send/acknowledge receipt).
- AddWatch should always modify watch, in case watch description from OS changes (e.g. due to move, delete/re-add, etc)
Also, added a test for this: TestInotifyDeleteReAdd
Fixes issue 2483.
Patch Set 1 #Patch Set 2 : diff -r 6abf04c86097 https://code.google.com/p/go/ #
Total comments: 1
Patch Set 3 : diff -r 6abf04c86097 https://code.google.com/p/go/ #Patch Set 4 : diff -r 6abf04c86097 https://code.google.com/p/go/ #
Total comments: 6
Patch Set 5 : diff -r c8f7a5a37d09 https://code.google.com/p/go/ #MessagesTotal messages: 13
|