This repository has been archived by the owner on May 4, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
linux: try inotify_init if inotify_init1 returns ENOSYS
The kernel may be older than the kernel headers that libuv is compiled against.
- Loading branch information
66a959c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Ben, wouldn't your logic be expressed a little simpler if we refactor the code into following:
66a959c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain what you feel is not simple about the current approach?
By the way, there's a bug in your patch's logic: it fails to set the FD_CLOEXEC flag if
inotify_init1()
returned ENOSYS.errno
is only set on error, syscalls that succeed don't touch it.It also retries if
inotify_init1()
fails with e.g. EMFILE or ENOMEM. Masking errors like that is generally considered an undesirable trait.66a959c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure of the reason why the code goes from return fd to return -1 two times and then have to return fd at the end.
Not sure what the meaning of static int new_inotify_fd(void) {} before the final return as well. Could you tell me more?
66a959c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fd
instead ofreturn -1
would work too because fd is -1 is at that point butreturn -1
takes less brain cycles to process because you don't have to look up (or infer) the value of fd in your mental database of variables.It's a patch marker, something that git inserts. It's not actual code.