fsnotify
fsnotify copied to clipboard
ln -sf only appears as DELETE on linux
ln -sf /var/log/scribe/wtf_125 /var/log/scribe/wtf_current
appears as:
2014/07/08 13:28:03 "/var/log/scribe/wtf_current": DELETE
in strace it looks like this
:
stat("/var/log/scribe/wtf_current", {st_mode=S_IFREG|0600, st_size=29, ...}) = 0
lstat("/var/log/scribe/wtf_current", {st_mode=S_IFLNK|0777, st_size=23, ...}) = 0
stat("/var/log/scribe/wtf_125", {st_mode=S_IFREG|0600, st_size=29, ...}) = 0
symlink("/var/log/scribe/wtf_125", "/var/log/scribe/wtf_current") = -1 EEXIST (File exists)
unlink("/var/log/scribe/wtf_current") = 0
symlink("/var/log/scribe/wtf_125", "/var/log/scribe/wtf_current") = 0
At the same time, this works as expected:
rm /var/log/scribe/wtf_current; ln -s /var/log/scribe/wtf_125 /var/log/scribe/wtf_current
2014/07/08 13:29:23 "/var/log/scribe/wtf_current": DELETE
2014/07/08 13:29:23 "/var/log/scribe/wtf_current": CREATE
unlinkat(AT_FDCWD, "/var/log/scribe/wtf_current", 0) = 0
... different process ...
stat("/var/log/scribe/wtf_current", 0x7fffcbc6baa0) = -1 ENOENT (No such file or directory)
symlink("/var/log/scribe/wtf_125", "/var/log/scribe/wtf_current") = 0
The next C program gives correct events with probability ~80%:
#include <unistd.h>
int main() {
unlink("/var/log/scribe/wtf_current");
usleep(1);
symlink("/var/log/scribe/wtf_125", "/var/log/scribe/wtf_current");
return 0;
}
Removing usleep
leads to absence of CREATE
events.
I suspect race condition somewhere.
Whoa:
2014/07/08 13:57:43 sending to internalEvent: "/var/log/scribe/wtf/wtf_current": DELETE
2014/07/08 13:57:43 sending to internalEvent: "/var/log/scribe/wtf/wtf_current": CREATE
2014/07/08 13:57:43 purgeEvents event: "/var/log/scribe/wtf/wtf_current": DELETE sendEvent: true
2014/07/08 13:57:43 purgeEvents event: "/var/log/scribe/wtf/wtf_current": CREATE sendEvent: false
Thanks for the thorough bug report with all the steps to reproduce.
Would you mind testing against github.com/fsnotify/fsnotify and opening a new issue at https://github.com/fsnotify/fsnotify/issues/new if the race condition persists?
(See #101)
@nathany I just did, it seems to be working in your version. I migrated to it already, thanks! (Although I'd keep Is*
methods in Event
).
It is more verbose than when it had the Is* methods. The nice thing is that it's easy to coalesce events together. The API isn't final by any means, but what's at fsnotify/fsnotify is close to what we came up with. (API doc http://goo.gl/MrYxyA)
@tianon I'm thinking of renaming fsnotify/fsnotify one more time. See the conversation here: https://github.com/fsnotify/fsnotify/issues/28. Sorry if your stuff breaks.