summaryrefslogtreecommitdiff
path: root/deps/uv/src/unix/linux-inotify.c
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-07-16 21:04:31 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2013-07-20 12:04:35 +0200
commit0e48cb4998a89a2adae95d97f3bce5f89c77d762 (patch)
tree754bf7e9765fbeb8f0fe9418d9d399335c7c7af8 /deps/uv/src/unix/linux-inotify.c
parent221c689ebbac9bda42c005b7f0278ce420766b22 (diff)
downloadandroid-node-v8-0e48cb4998a89a2adae95d97f3bce5f89c77d762.tar.gz
android-node-v8-0e48cb4998a89a2adae95d97f3bce5f89c77d762.tar.bz2
android-node-v8-0e48cb4998a89a2adae95d97f3bce5f89c77d762.zip
deps: upgrade libuv to 3ee4d3f
Diffstat (limited to 'deps/uv/src/unix/linux-inotify.c')
-rw-r--r--deps/uv/src/unix/linux-inotify.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/deps/uv/src/unix/linux-inotify.c b/deps/uv/src/unix/linux-inotify.c
index af0242477e..4bf30dbf7b 100644
--- a/deps/uv/src/unix/linux-inotify.c
+++ b/deps/uv/src/unix/linux-inotify.c
@@ -62,20 +62,27 @@ static void uv__inotify_read(uv_loop_t* loop,
static int new_inotify_fd(void) {
+ int err;
int fd;
fd = uv__inotify_init1(UV__IN_NONBLOCK | UV__IN_CLOEXEC);
if (fd != -1)
return fd;
+
if (errno != ENOSYS)
- return -1;
+ return -errno;
+
+ fd = uv__inotify_init();
+ if (fd == -1)
+ return -errno;
- if ((fd = uv__inotify_init()) == -1)
- return -1;
+ err = uv__cloexec(fd, 1);
+ if (err == 0)
+ err = uv__nonblock(fd, 1);
- if (uv__cloexec(fd, 1) || uv__nonblock(fd, 1)) {
- SAVE_ERRNO(close(fd));
- return -1;
+ if (err) {
+ close(fd);
+ return err;
}
return fd;
@@ -83,15 +90,16 @@ static int new_inotify_fd(void) {
static int init_inotify(uv_loop_t* loop) {
+ int err;
+
if (loop->inotify_fd != -1)
return 0;
- loop->inotify_fd = new_inotify_fd();
- if (loop->inotify_fd == -1) {
- uv__set_sys_error(loop, errno);
- return -1;
- }
+ err = new_inotify_fd();
+ if (err < 0)
+ return err;
+ loop->inotify_fd = err;
uv__io_init(&loop->inotify_read_watcher, uv__inotify_read, loop->inotify_fd);
uv__io_start(loop, &loop->inotify_read_watcher, UV__POLLIN);
@@ -167,9 +175,12 @@ int uv_fs_event_init(uv_loop_t* loop,
int flags) {
struct watcher_list* w;
int events;
+ int err;
int wd;
- if (init_inotify(loop)) return -1;
+ err = init_inotify(loop);
+ if (err)
+ return err;
events = UV__IN_ATTRIB
| UV__IN_CREATE
@@ -182,7 +193,7 @@ int uv_fs_event_init(uv_loop_t* loop,
wd = uv__inotify_add_watch(loop->inotify_fd, path, events);
if (wd == -1)
- return uv__set_sys_error(loop, errno);
+ return -errno;
w = find_watcher(loop, wd);
if (w)
@@ -190,7 +201,7 @@ int uv_fs_event_init(uv_loop_t* loop,
w = malloc(sizeof(*w) + strlen(path) + 1);
if (w == NULL)
- return uv__set_sys_error(loop, ENOMEM);
+ return -ENOMEM;
w->wd = wd;
w->path = strcpy((char*)(w + 1), path);