node-inotify
node-inotify copied to clipboard
node-inotify needs to use another way to save the callbacks other than the watch file descriptor as key
node-inotify needs to use another way to save the callbacks other than the watch file descriptor as key. When you make a removeWatch and a subsequent addWatch, inotify is using the same watch descriptor which is problematic because when the last event of the removed watch arrive, the callback deleted belongs to the new addWatch which is completely wrong !
This is a segfault issue, with a simple fix. (I worked around it by making sure to add before removing.)
The easy fix: in AddWatch(), before calling inotify->handle_->Set(descriptor, args_->Get(callback_sym)); throw an error if the descriptor already has a value.
Ok, I will do this as a work around. The best solution is using a hash (sha1?) as object key instead of the watch file descriptor. We can use maybe the crypto module that comes with NodeJS and use as key the Watch File Descriptor for the module to generate the hash.