node-inotify icon indicating copy to clipboard operation
node-inotify copied to clipboard

node-inotify needs to use another way to save the callbacks other than the watch file descriptor as key

Open c4milo opened this issue 15 years ago • 2 comments

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 !

c4milo avatar Oct 27 '10 12:10 c4milo

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.

networkimprov avatar Dec 19 '10 22:12 networkimprov

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.

c4milo avatar Dec 20 '10 17:12 c4milo