From af7960b29525ec28ca58617e9b06c8b0df3085cd Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Feb 2012 18:11:48 +0100 Subject: [PATCH] uv: upgrade to 2f886c8 --- deps/uv/.gitignore | 2 + deps/uv/config-unix.mk | 2 +- deps/uv/include/uv-private/uv-unix.h | 28 ++- deps/uv/include/uv.h | 2 + deps/uv/src/unix/core.c | 52 +++-- deps/uv/src/unix/darwin.c | 5 +- deps/uv/src/unix/ev/ev.c | 1 + deps/uv/src/unix/freebsd.c | 21 ++ deps/uv/src/unix/internal.h | 14 +- deps/uv/src/unix/{linux.c => linux/core.c} | 267 ++--------------------- deps/uv/src/unix/linux/inotify.c | 329 +++++++++++++++++++++++++++++ deps/uv/src/unix/netbsd.c | 4 - deps/uv/src/unix/openbsd.c | 31 +-- deps/uv/src/unix/process.c | 4 + deps/uv/src/uv-common.c | 9 +- deps/uv/src/uv-common.h | 6 +- deps/uv/src/win/fs.c | 8 +- deps/uv/src/win/internal.h | 4 + deps/uv/src/win/tcp.c | 10 +- deps/uv/src/win/winsock.c | 53 ++++- deps/uv/test/run-tests.c | 4 +- deps/uv/test/test-fs.c | 8 + deps/uv/uv.gyp | 5 +- 23 files changed, 568 insertions(+), 301 deletions(-) rename deps/uv/src/unix/{linux.c => linux/core.c} (66%) create mode 100644 deps/uv/src/unix/linux/inotify.c diff --git a/deps/uv/.gitignore b/deps/uv/.gitignore index 9739d09..fa9636d 100644 --- a/deps/uv/.gitignore +++ b/deps/uv/.gitignore @@ -29,3 +29,5 @@ UpgradeLog*.XML Debug Release ipch +*.mk +*.Makefile diff --git a/deps/uv/config-unix.mk b/deps/uv/config-unix.mk index 045987f..8eb1c6e 100644 --- a/deps/uv/config-unix.mk +++ b/deps/uv/config-unix.mk @@ -63,7 +63,7 @@ EIO_CONFIG=config_linux.h CSTDFLAG += -D_GNU_SOURCE CPPFLAGS += -Isrc/ares/config_linux LINKFLAGS+=-lrt -OBJS += src/unix/linux.o +OBJS += src/unix/linux/core.o src/unix/linux/inotify.o endif ifeq (FreeBSD,$(uname_S)) diff --git a/deps/uv/include/uv-private/uv-unix.h b/deps/uv/include/uv-private/uv-unix.h index 24ef37c..4ce1cf8 100644 --- a/deps/uv/include/uv-private/uv-unix.h +++ b/deps/uv/include/uv-private/uv-unix.h @@ -55,6 +55,18 @@ typedef pthread_rwlock_t uv_rwlock_t; typedef void* uv_lib_t; #define UV_DYNAMIC /* empty */ +#if __linux__ +# define UV_LOOP_PRIVATE_PLATFORM_FIELDS \ + /* RB_HEAD(uv__inotify_watchers, uv_fs_event_s) */ \ + struct uv__inotify_watchers { \ + struct uv_fs_event_s* rbh_root; \ + } inotify_watchers; \ + ev_io inotify_read_watcher; \ + int inotify_fd; +#else +# define UV_LOOP_PRIVATE_PLATFORM_FIELDS +#endif + #define UV_LOOP_PRIVATE_FIELDS \ ares_channel channel; \ /* \ @@ -65,7 +77,8 @@ typedef void* uv_lib_t; ev_timer timer; \ /* Poll result queue */ \ eio_channel uv_eio_channel; \ - struct ev_loop* ev; + struct ev_loop* ev; \ + UV_LOOP_PRIVATE_PLATFORM_FIELDS #define UV_REQ_BUFSML_SIZE (4) @@ -195,9 +208,16 @@ typedef void* uv_lib_t; /* UV_FS_EVENT_PRIVATE_FIELDS */ #if defined(__linux__) -#define UV_FS_EVENT_PRIVATE_FIELDS \ - ev_io read_watcher; \ - uv_fs_event_cb cb; \ +#define UV_FS_EVENT_PRIVATE_FIELDS \ + /* RB_ENTRY(fs_event_s) node; */ \ + struct { \ + struct uv_fs_event_s* rbe_left; \ + struct uv_fs_event_s* rbe_right; \ + struct uv_fs_event_s* rbe_parent; \ + int rbe_color; \ + } node; \ + ev_io read_watcher; \ + uv_fs_event_cb cb; #elif (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060) \ || defined(__FreeBSD__) \ diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h index f4ee49c..4af154e 100644 --- a/deps/uv/include/uv.h +++ b/deps/uv/include/uv.h @@ -1504,6 +1504,8 @@ struct uv_loop_s { #undef UV_FS_REQ_PRIVATE_FIELDS #undef UV_WORK_PRIVATE_FIELDS #undef UV_FS_EVENT_PRIVATE_FIELDS +#undef UV_LOOP_PRIVATE_FIELDS +#undef UV_LOOP_PRIVATE_PLATFORM_FIELDS #ifdef __cplusplus } diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c index af39fc8..728eb0b 100644 --- a/deps/uv/src/unix/core.c +++ b/deps/uv/src/unix/core.c @@ -65,7 +65,6 @@ static void uv__finish_close(uv_handle_t* handle); void uv_close(uv_handle_t* handle, uv_close_cb close_cb) { uv_async_t* async; - uv_timer_t* timer; uv_stream_t* stream; uv_process_t* process; @@ -118,11 +117,7 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) { break; case UV_TIMER: - timer = (uv_timer_t*)handle; - if (ev_is_active(&timer->timer_watcher)) { - ev_ref(timer->loop->ev); - } - ev_timer_stop(timer->loop->ev, &timer->timer_watcher); + uv_timer_stop((uv_timer_t*)handle); break; case UV_PROCESS: @@ -157,6 +152,7 @@ static int uv__loop_init(uv_loop_t* loop, #endif ev_set_userdata(loop->ev, loop); eio_channel_init(&loop->uv_eio_channel, loop); + uv__loop_platform_init(loop); return 0; } @@ -179,11 +175,10 @@ uv_loop_t* uv_loop_new(void) { void uv_loop_delete(uv_loop_t* loop) { uv_ares_destroy(loop, loop->channel); ev_loop_destroy(loop->ev); - + uv__loop_platform_delete(loop); #ifndef NDEBUG - memset(loop, 0, sizeof *loop); + memset(loop, -1, sizeof *loop); #endif - if (loop == default_loop_ptr) default_loop_ptr = NULL; else @@ -531,10 +526,23 @@ int uv_async_send(uv_async_t* async) { } +static int uv__timer_active(const uv_timer_t* timer) { + return timer->flags & UV_TIMER_ACTIVE; +} + + +static int uv__timer_repeating(const uv_timer_t* timer) { + return timer->flags & UV_TIMER_REPEAT; +} + + static void uv__timer_cb(EV_P_ ev_timer* w, int revents) { uv_timer_t* timer = container_of(w, uv_timer_t, timer_watcher); - if (!ev_is_active(w)) { + assert(uv__timer_active(timer)); + + if (!uv__timer_repeating(timer)) { + timer->flags &= ~UV_TIMER_ACTIVE; ev_ref(EV_A); } @@ -556,43 +564,61 @@ int uv_timer_init(uv_loop_t* loop, uv_timer_t* timer) { int uv_timer_start(uv_timer_t* timer, uv_timer_cb cb, int64_t timeout, int64_t repeat) { - if (ev_is_active(&timer->timer_watcher)) { + if (uv__timer_active(timer)) { return -1; } timer->timer_cb = cb; + timer->flags |= UV_TIMER_ACTIVE; + + if (repeat) + timer->flags |= UV_TIMER_REPEAT; + else + timer->flags &= ~UV_TIMER_REPEAT; + ev_timer_set(&timer->timer_watcher, timeout / 1000.0, repeat / 1000.0); ev_timer_start(timer->loop->ev, &timer->timer_watcher); ev_unref(timer->loop->ev); + return 0; } int uv_timer_stop(uv_timer_t* timer) { - if (ev_is_active(&timer->timer_watcher)) { + if (uv__timer_active(timer)) { ev_ref(timer->loop->ev); } + timer->flags &= ~(UV_TIMER_ACTIVE | UV_TIMER_REPEAT); ev_timer_stop(timer->loop->ev, &timer->timer_watcher); + return 0; } int uv_timer_again(uv_timer_t* timer) { - if (!ev_is_active(&timer->timer_watcher)) { + if (!uv__timer_active(timer)) { uv__set_sys_error(timer->loop, EINVAL); return -1; } + assert(uv__timer_repeating(timer)); ev_timer_again(timer->loop->ev, &timer->timer_watcher); return 0; } + void uv_timer_set_repeat(uv_timer_t* timer, int64_t repeat) { assert(timer->type == UV_TIMER); timer->timer_watcher.repeat = repeat / 1000.0; + + if (repeat) + timer->flags |= UV_TIMER_REPEAT; + else + timer->flags &= ~UV_TIMER_REPEAT; } + int64_t uv_timer_get_repeat(uv_timer_t* timer) { assert(timer->type == UV_TIMER); return (int64_t)(1000 * timer->timer_watcher.repeat); diff --git a/deps/uv/src/unix/darwin.c b/deps/uv/src/unix/darwin.c index e6deb30..6b3705f 100644 --- a/deps/uv/src/unix/darwin.c +++ b/deps/uv/src/unix/darwin.c @@ -73,7 +73,6 @@ uint64_t uv_hrtime() { int uv_exepath(char* buffer, size_t* size) { uint32_t usize; int result; - char* path; char* fullpath; if (!buffer || !size) { @@ -84,11 +83,9 @@ int uv_exepath(char* buffer, size_t* size) { result = _NSGetExecutablePath(buffer, &usize); if (result) return result; - path = (char*)malloc(2 * PATH_MAX); - fullpath = realpath(buffer, path); + fullpath = realpath(buffer, NULL); if (fullpath == NULL) { - free(path); return -1; } diff --git a/deps/uv/src/unix/ev/ev.c b/deps/uv/src/unix/ev/ev.c index b6e190f..a432bfb 100644 --- a/deps/uv/src/unix/ev/ev.c +++ b/deps/uv/src/unix/ev/ev.c @@ -2554,6 +2554,7 @@ void ev_unref (EV_P) { --activecnt; + if (activecnt < 0) abort(); } void diff --git a/deps/uv/src/unix/freebsd.c b/deps/uv/src/unix/freebsd.c index 9b83d34..1e2c1d4 100644 --- a/deps/uv/src/unix/freebsd.c +++ b/deps/uv/src/unix/freebsd.c @@ -40,6 +40,16 @@ #undef NANOSEC #define NANOSEC 1000000000 +#ifndef CPUSTATES +# define CPUSTATES 5U +#endif +#ifndef CP_USER +# define CP_USER 0 +# define CP_NICE 1 +# define CP_SYS 2 +# define CP_IDLE 3 +# define CP_INTR 4 +#endif static char *process_title; @@ -164,7 +174,11 @@ uv_err_t uv_resident_set_memory(size_t* rss) { kinfo = kvm_getprocs(kd, KERN_PROC_PID, pid, &nprocs); if (kinfo == NULL) goto error; +#ifdef __DragonFly__ + *rss = kinfo->kp_vm_rssize * page_size; +#else *rss = kinfo->ki_rssize * page_size; +#endif kvm_close(kd); @@ -227,10 +241,17 @@ uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { } /* kern.cp_times on FreeBSD i386 gives an array up to maxcpus instead of ncpu */ size = sizeof(maxcpus); +#ifdef __DragonFly__ + if (sysctlbyname("hw.ncpu", &maxcpus, &size, NULL, 0) < 0) { + free(*cpu_infos); + return uv__new_sys_error(errno); + } +#else if (sysctlbyname("kern.smp.maxcpus", &maxcpus, &size, NULL, 0) < 0) { free(*cpu_infos); return uv__new_sys_error(errno); } +#endif size = maxcpus * CPUSTATES * sizeof(long); diff --git a/deps/uv/src/unix/internal.h b/deps/uv/src/unix/internal.h index 3591090..8a3453e 100644 --- a/deps/uv/src/unix/internal.h +++ b/deps/uv/src/unix/internal.h @@ -160,7 +160,9 @@ enum { UV_READABLE = 0x20, /* The stream is readable */ UV_WRITABLE = 0x40, /* The stream is writable */ UV_TCP_NODELAY = 0x080, /* Disable Nagle. */ - UV_TCP_KEEPALIVE = 0x100 /* Turn on keep-alive. */ + UV_TCP_KEEPALIVE = 0x100, /* Turn on keep-alive. */ + UV_TIMER_ACTIVE = 0x080, + UV_TIMER_REPEAT = 0x100 }; /* core */ @@ -217,4 +219,14 @@ void uv__fs_event_destroy(uv_fs_event_t* handle); int uv__make_socketpair(int fds[2], int flags); int uv__make_pipe(int fds[2], int flags); +#if __linux__ +void uv__inotify_loop_init(uv_loop_t* loop); +void uv__inotify_loop_delete(uv_loop_t* loop); +# define uv__loop_platform_init(loop) uv__inotify_loop_init(loop) +# define uv__loop_platform_delete(loop) uv__inotify_loop_delete(loop) +#else +# define uv__loop_platform_init(loop) +# define uv__loop_platform_delete(loop) +#endif + #endif /* UV_UNIX_INTERNAL_H_ */ diff --git a/deps/uv/src/unix/linux.c b/deps/uv/src/unix/linux/core.c similarity index 66% rename from deps/uv/src/unix/linux.c rename to deps/uv/src/unix/linux/core.c index 2f04cb8..88c92f4 100644 --- a/deps/uv/src/unix/linux.c +++ b/deps/uv/src/unix/linux/core.c @@ -19,7 +19,7 @@ */ #include "uv.h" -#include "internal.h" +#include "../internal.h" #include #include @@ -28,7 +28,6 @@ #include #include -#include #include #include #include @@ -36,93 +35,18 @@ #include #include -#undef NANOSEC -#define NANOSEC 1000000000 - -#undef HAVE_INOTIFY_INIT -#undef HAVE_INOTIFY_INIT1 -#undef HAVE_INOTIFY_ADD_WATCH -#undef HAVE_INOTIFY_RM_WATCH - -#if __NR_inotify_init -# define HAVE_INOTIFY_INIT 1 -#endif -#if __NR_inotify_init1 -# define HAVE_INOTIFY_INIT1 1 +#define HAVE_IFADDRS_H 1 +#ifdef __UCLIBC__ +# if __UCLIBC_MAJOR__ < 0 || __UCLIBC_MINOR__ < 9 || __UCLIBC_SUBLEVEL__ < 32 +# undef HAVE_IFADDRS_H +# endif #endif -#if __NR_inotify_add_watch -# define HAVE_INOTIFY_ADD_WATCH 1 +#ifdef HAVE_IFADDRS_H +# include #endif -#if __NR_inotify_rm_watch -# define HAVE_INOTIFY_RM_WATCH 1 -#endif - -#if HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1 -# undef IN_ACCESS -# undef IN_MODIFY -# undef IN_ATTRIB -# undef IN_CLOSE_WRITE -# undef IN_CLOSE_NOWRITE -# undef IN_OPEN -# undef IN_MOVED_FROM -# undef IN_MOVED_TO -# undef IN_CREATE -# undef IN_DELETE -# undef IN_DELETE_SELF -# undef IN_MOVE_SELF -# define IN_ACCESS 0x001 -# define IN_MODIFY 0x002 -# define IN_ATTRIB 0x004 -# define IN_CLOSE_WRITE 0x008 -# define IN_CLOSE_NOWRITE 0x010 -# define IN_OPEN 0x020 -# define IN_MOVED_FROM 0x040 -# define IN_MOVED_TO 0x080 -# define IN_CREATE 0x100 -# define IN_DELETE 0x200 -# define IN_DELETE_SELF 0x400 -# define IN_MOVE_SELF 0x800 -struct inotify_event { - int32_t wd; - uint32_t mask; - uint32_t cookie; - uint32_t len; - /* char name[0]; */ -}; -#endif /* HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1 */ - -#undef IN_CLOEXEC -#undef IN_NONBLOCK - -#if HAVE_INOTIFY_INIT1 -# define IN_CLOEXEC O_CLOEXEC -# define IN_NONBLOCK O_NONBLOCK -#endif /* HAVE_INOTIFY_INIT1 */ - -#if HAVE_INOTIFY_INIT -inline static int inotify_init(void) { - return syscall(__NR_inotify_init); -} -#endif /* HAVE_INOTIFY_INIT */ - -#if HAVE_INOTIFY_INIT1 -inline static int inotify_init1(int flags) { - return syscall(__NR_inotify_init1, flags); -} -#endif /* HAVE_INOTIFY_INIT1 */ - -#if HAVE_INOTIFY_ADD_WATCH -inline static int inotify_add_watch(int fd, const char* path, uint32_t mask) { - return syscall(__NR_inotify_add_watch, fd, path, mask); -} -#endif /* HAVE_INOTIFY_ADD_WATCH */ - -#if HAVE_INOTIFY_RM_WATCH -inline static int inotify_rm_watch(int fd, uint32_t wd) { - return syscall(__NR_inotify_rm_watch, fd, wd); -} -#endif /* HAVE_INOTIFY_RM_WATCH */ +#undef NANOSEC +#define NANOSEC 1000000000 static char buf[MAXPATHLEN + 1]; @@ -132,13 +56,6 @@ static struct { } process_title; -/* Don't look aghast, this is exactly how glibc's basename() works. */ -static char* basename_r(const char* path) { - char* s = strrchr(path, '/'); - return s ? (s + 1) : (char*)path; -} - - /* * There's probably some way to get time from Linux than gettimeofday(). What * it is, I don't know. @@ -162,13 +79,17 @@ void uv_loadavg(double avg[3]) { int uv_exepath(char* buffer, size_t* size) { + ssize_t n; + if (!buffer || !size) { return -1; } - *size = readlink("/proc/self/exe", buffer, *size - 1); - if (*size <= 0) return -1; - buffer[*size] = '\0'; + n = readlink("/proc/self/exe", buffer, *size - 1); + if (n <= 0) return -1; + buffer[n] = '\0'; + *size = n; + return 0; } @@ -457,6 +378,9 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { uv_err_t uv_interface_addresses(uv_interface_address_t** addresses, int* count) { +#ifndef HAVE_IFADDRS_H + return uv__new_artificial_error(UV_ENOSYS); +#else struct ifaddrs *addrs, *ent; char ip[INET6_ADDRSTRLEN]; uv_interface_address_t* address; @@ -520,6 +444,7 @@ uv_err_t uv_interface_addresses(uv_interface_address_t** addresses, freeifaddrs(addrs); return uv_ok_; +#endif } @@ -533,153 +458,3 @@ void uv_free_interface_addresses(uv_interface_address_t* addresses, free(addresses); } - -#if HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1 - -static int new_inotify_fd(void) { -#if HAVE_INOTIFY_INIT1 - return inotify_init1(IN_NONBLOCK | IN_CLOEXEC); -#else - int fd; - - if ((fd = inotify_init()) == -1) - return -1; - - if (uv__cloexec(fd, 1) || uv__nonblock(fd, 1)) { - SAVE_ERRNO(uv__close(fd)); - fd = -1; - } - - return fd; -#endif -} - - -static void uv__inotify_read(EV_P_ ev_io* w, int revents) { - struct inotify_event* e; - uv_fs_event_t* handle; - const char* filename; - ssize_t size; - int events; - char *p; - /* needs to be large enough for sizeof(inotify_event) + strlen(filename) */ - char buf[4096]; - - handle = container_of(w, uv_fs_event_t, read_watcher); - - do { - do { - size = read(handle->fd, buf, sizeof buf); - } - while (size == -1 && errno == EINTR); - - if (size == -1) { - assert(errno == EAGAIN || errno == EWOULDBLOCK); - break; - } - - assert(size > 0); /* pre-2.6.21 thing, size=0 == read buffer too small */ - - /* Now we have one or more inotify_event structs. */ - for (p = buf; p < buf + size; p += sizeof(*e) + e->len) { - e = (void*)p; - - events = 0; - if (e->mask & (IN_ATTRIB|IN_MODIFY)) - events |= UV_CHANGE; - if (e->mask & ~(IN_ATTRIB|IN_MODIFY)) - events |= UV_RENAME; - - /* inotify does not return the filename when monitoring a single file - * for modifications. Repurpose the filename for API compatibility. - * I'm not convinced this is a good thing, maybe it should go. - */ - filename = e->len ? (const char*) (e + 1) : basename_r(handle->filename); - - handle->cb(handle, filename, events, 0); - - if (handle->fd == -1) - break; - } - } - while (handle->fd != -1); /* handle might've been closed by callback */ -} - - -int uv_fs_event_init(uv_loop_t* loop, - uv_fs_event_t* handle, - const char* filename, - uv_fs_event_cb cb, - int flags) { - int events; - int fd; - - loop->counters.fs_event_init++; - - /* We don't support any flags yet. */ - assert(!flags); - - /* - * TODO share a single inotify fd across the event loop? - * We'll run into fs.inotify.max_user_instances if we - * keep creating new inotify fds. - */ - if ((fd = new_inotify_fd()) == -1) { - uv__set_sys_error(loop, errno); - return -1; - } - - events = IN_ATTRIB - | IN_CREATE - | IN_MODIFY - | IN_DELETE - | IN_DELETE_SELF - | IN_MOVED_FROM - | IN_MOVED_TO; - - if (inotify_add_watch(fd, filename, events) == -1) { - uv__set_sys_error(loop, errno); - uv__close(fd); - return -1; - } - - uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT); - handle->filename = strdup(filename); /* this should go! */ - handle->cb = cb; - handle->fd = fd; - - ev_io_init(&handle->read_watcher, uv__inotify_read, fd, EV_READ); - ev_io_start(loop->ev, &handle->read_watcher); - ev_unref(loop->ev); - - return 0; -} - - -void uv__fs_event_destroy(uv_fs_event_t* handle) { - ev_ref(handle->loop->ev); - ev_io_stop(handle->loop->ev, &handle->read_watcher); - uv__close(handle->fd); - handle->fd = -1; - free(handle->filename); - handle->filename = NULL; -} - -#else /* !HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1 */ - -int uv_fs_event_init(uv_loop_t* loop, - uv_fs_event_t* handle, - const char* filename, - uv_fs_event_cb cb, - int flags) { - loop->counters.fs_event_init++; - uv__set_sys_error(loop, ENOSYS); - return -1; -} - - -void uv__fs_event_destroy(uv_fs_event_t* handle) { - UNREACHABLE(); -} - -#endif /* HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1 */ diff --git a/deps/uv/src/unix/linux/inotify.c b/deps/uv/src/unix/linux/inotify.c new file mode 100644 index 0000000..609be97 --- /dev/null +++ b/deps/uv/src/unix/linux/inotify.c @@ -0,0 +1,329 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "uv.h" +#include "tree.h" +#include "../internal.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#undef HAVE_INOTIFY_INIT +#undef HAVE_INOTIFY_INIT1 +#undef HAVE_INOTIFY_ADD_WATCH +#undef HAVE_INOTIFY_RM_WATCH + +#if __NR_inotify_init +# define HAVE_INOTIFY_INIT 1 +#endif +#if __NR_inotify_init1 +# define HAVE_INOTIFY_INIT1 1 +#endif +#if __NR_inotify_add_watch +# define HAVE_INOTIFY_ADD_WATCH 1 +#endif +#if __NR_inotify_rm_watch +# define HAVE_INOTIFY_RM_WATCH 1 +#endif + +#if HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1 +# undef IN_ACCESS +# undef IN_MODIFY +# undef IN_ATTRIB +# undef IN_CLOSE_WRITE +# undef IN_CLOSE_NOWRITE +# undef IN_OPEN +# undef IN_MOVED_FROM +# undef IN_MOVED_TO +# undef IN_CREATE +# undef IN_DELETE +# undef IN_DELETE_SELF +# undef IN_MOVE_SELF +# define IN_ACCESS 0x001 +# define IN_MODIFY 0x002 +# define IN_ATTRIB 0x004 +# define IN_CLOSE_WRITE 0x008 +# define IN_CLOSE_NOWRITE 0x010 +# define IN_OPEN 0x020 +# define IN_MOVED_FROM 0x040 +# define IN_MOVED_TO 0x080 +# define IN_CREATE 0x100 +# define IN_DELETE 0x200 +# define IN_DELETE_SELF 0x400 +# define IN_MOVE_SELF 0x800 +struct inotify_event { + int32_t wd; + uint32_t mask; + uint32_t cookie; + uint32_t len; + /* char name[0]; */ +}; +#endif /* HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1 */ + +#undef IN_CLOEXEC +#undef IN_NONBLOCK + +#if HAVE_INOTIFY_INIT1 +# define IN_CLOEXEC O_CLOEXEC +# define IN_NONBLOCK O_NONBLOCK +#endif /* HAVE_INOTIFY_INIT1 */ + +#if HAVE_INOTIFY_INIT +inline static int inotify_init(void) { + return syscall(__NR_inotify_init); +} +#endif /* HAVE_INOTIFY_INIT */ + +#if HAVE_INOTIFY_INIT1 +inline static int inotify_init1(int flags) { + return syscall(__NR_inotify_init1, flags); +} +#endif /* HAVE_INOTIFY_INIT1 */ + +#if HAVE_INOTIFY_ADD_WATCH +inline static int inotify_add_watch(int fd, const char* path, uint32_t mask) { + return syscall(__NR_inotify_add_watch, fd, path, mask); +} +#endif /* HAVE_INOTIFY_ADD_WATCH */ + +#if HAVE_INOTIFY_RM_WATCH +inline static int inotify_rm_watch(int fd, uint32_t wd) { + return syscall(__NR_inotify_rm_watch, fd, wd); +} +#endif /* HAVE_INOTIFY_RM_WATCH */ + + +/* Don't look aghast, this is exactly how glibc's basename() works. */ +static char* basename_r(const char* path) { + char* s = strrchr(path, '/'); + return s ? (s + 1) : (char*)path; +} + + +static int compare_watchers(const uv_fs_event_t* a, const uv_fs_event_t* b) { + if (a->fd < b->fd) return -1; + if (a->fd > b->fd) return 1; + return 0; +} + + +RB_GENERATE_INTERNAL(uv__inotify_watchers, uv_fs_event_s, node, compare_watchers, + inline static __attribute__((unused))) + + +void uv__inotify_loop_init(uv_loop_t* loop) { + RB_INIT(&loop->inotify_watchers); + loop->inotify_fd = -1; +} + + +void uv__inotify_loop_delete(uv_loop_t* loop) { + if (loop->inotify_fd == -1) return; + ev_io_stop(loop->ev, &loop->inotify_read_watcher); + close(loop->inotify_fd); + loop->inotify_fd = -1; +} + + +#if HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1 + +static void uv__inotify_read(EV_P_ ev_io* w, int revents); + + +static int new_inotify_fd(void) { +#if HAVE_INOTIFY_INIT1 + return inotify_init1(IN_NONBLOCK | IN_CLOEXEC); +#else + int fd; + + if ((fd = inotify_init()) == -1) + return -1; + + if (uv__cloexec(fd, 1) || uv__nonblock(fd, 1)) { + SAVE_ERRNO(uv__close(fd)); + return -1; + } + + return fd; +#endif +} + + +static int init_inotify(uv_loop_t* loop) { + 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; + } + + ev_io_init(&loop->inotify_read_watcher, + uv__inotify_read, + loop->inotify_fd, + EV_READ); + ev_io_start(loop->ev, &loop->inotify_read_watcher); + ev_unref(loop->ev); + + return 0; +} + + +static void add_watcher(uv_fs_event_t* handle) { + RB_INSERT(uv__inotify_watchers, &handle->loop->inotify_watchers, handle); +} + + +static uv_fs_event_t* find_watcher(uv_loop_t* loop, int wd) { + uv_fs_event_t handle; + handle.fd = wd; + return RB_FIND(uv__inotify_watchers, &loop->inotify_watchers, &handle); +} + + +static void remove_watcher(uv_fs_event_t* handle) { + RB_REMOVE(uv__inotify_watchers, &handle->loop->inotify_watchers, handle); +} + + +static void uv__inotify_read(EV_P_ ev_io* w, int revents) { + const struct inotify_event* e; + uv_fs_event_t* handle; + uv_loop_t* uv_loop; + const char* filename; + ssize_t size; + int events; + const char *p; + /* needs to be large enough for sizeof(inotify_event) + strlen(filename) */ + char buf[4096]; + + uv_loop = container_of(w, uv_loop_t, inotify_read_watcher); + + while (1) { + do { + size = read(uv_loop->inotify_fd, buf, sizeof buf); + } + while (size == -1 && errno == EINTR); + + if (size == -1) { + assert(errno == EAGAIN || errno == EWOULDBLOCK); + break; + } + + assert(size > 0); /* pre-2.6.21 thing, size=0 == read buffer too small */ + + /* Now we have one or more inotify_event structs. */ + for (p = buf; p < buf + size; p += sizeof(*e) + e->len) { + e = (const struct inotify_event*)p; + + events = 0; + if (e->mask & (IN_ATTRIB|IN_MODIFY)) + events |= UV_CHANGE; + if (e->mask & ~(IN_ATTRIB|IN_MODIFY)) + events |= UV_RENAME; + + handle = find_watcher(uv_loop, e->wd); + if (handle == NULL) + continue; /* Handle has already been closed. */ + + /* inotify does not return the filename when monitoring a single file + * for modifications. Repurpose the filename for API compatibility. + * I'm not convinced this is a good thing, maybe it should go. + */ + filename = e->len ? (const char*) (e + 1) : basename_r(handle->filename); + + handle->cb(handle, filename, events, 0); + } + } +} + + +int uv_fs_event_init(uv_loop_t* loop, + uv_fs_event_t* handle, + const char* filename, + uv_fs_event_cb cb, + int flags) { + int events; + int wd; + + loop->counters.fs_event_init++; + + /* We don't support any flags yet. */ + assert(!flags); + + if (init_inotify(loop)) return -1; + + events = IN_ATTRIB + | IN_CREATE + | IN_MODIFY + | IN_DELETE + | IN_DELETE_SELF + | IN_MOVED_FROM + | IN_MOVED_TO; + + wd = inotify_add_watch(loop->inotify_fd, filename, events); + if (wd == -1) return uv__set_sys_error(loop, errno); + + uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT); + handle->filename = strdup(filename); + handle->cb = cb; + handle->fd = wd; + add_watcher(handle); + + return 0; +} + + +void uv__fs_event_destroy(uv_fs_event_t* handle) { + inotify_rm_watch(handle->loop->inotify_fd, handle->fd); + remove_watcher(handle); + handle->fd = -1; + + free(handle->filename); + handle->filename = NULL; +} + +#else /* !HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1 */ + +int uv_fs_event_init(uv_loop_t* loop, + uv_fs_event_t* handle, + const char* filename, + uv_fs_event_cb cb, + int flags) { + loop->counters.fs_event_init++; + uv__set_sys_error(loop, ENOSYS); + return -1; +} + + +void uv__fs_event_destroy(uv_fs_event_t* handle) { + UNREACHABLE(); +} + +#endif /* HAVE_INOTIFY_INIT || HAVE_INOTIFY_INIT1 */ diff --git a/deps/uv/src/unix/netbsd.c b/deps/uv/src/unix/netbsd.c index cf83c34..2fedc94 100644 --- a/deps/uv/src/unix/netbsd.c +++ b/deps/uv/src/unix/netbsd.c @@ -54,10 +54,6 @@ void uv_loadavg(double avg[3]) { } int uv_exepath(char* buffer, size_t* size) { - uint32_t usize; - int result; - char* path; - char* fullpath; int mib[4]; size_t cb; pid_t mypid; diff --git a/deps/uv/src/unix/openbsd.c b/deps/uv/src/unix/openbsd.c index 80e934c..c8d4c92 100644 --- a/deps/uv/src/unix/openbsd.c +++ b/deps/uv/src/unix/openbsd.c @@ -18,13 +18,20 @@ * IN THE SOFTWARE. */ +#include "uv.h" +#include "internal.h" + #include #include #include +#include #include #include #include +#include +#include +#include #include #include #include @@ -159,9 +166,9 @@ uv_err_t uv_get_process_title(char* buffer, size_t size) { uv_err_t uv_resident_set_memory(size_t* rss) { kvm_t *kd = NULL; - struct kinfo_proc2 *kinfo = NULL; + struct kinfo_proc *kinfo = NULL; pid_t pid; - int nprocs, max_size = sizeof(struct kinfo_proc2); + int nprocs, max_size = sizeof(struct kinfo_proc); size_t page_size = getpagesize(); pid = getpid(); @@ -169,7 +176,7 @@ uv_err_t uv_resident_set_memory(size_t* rss) { kd = kvm_open(NULL, _PATH_MEM, NULL, O_RDONLY, "kvm_open"); if (kd == NULL) goto error; - kinfo = kvm_getproc2(kd, KERN_PROC_PID, pid, max_size, &nprocs); + kinfo = kvm_getprocs(kd, KERN_PROC_PID, pid, max_size, &nprocs); if (kinfo == NULL) goto error; *rss = kinfo->p_vm_rssize * page_size; @@ -207,18 +214,18 @@ uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { uint64_t info[CPUSTATES]; char model[512]; int numcpus = 1; - static int which[] = {CTL_HW, HW_MODEL, NULL}; + static int which[] = {CTL_HW,HW_MODEL,0}; size_t size; uv_cpu_info_t* cpu_info; size = sizeof(model); if (sysctl(which, 2, &model, &size, NULL, 0) < 0) { - return -1; + return uv__new_sys_error(errno); } which[1] = HW_NCPU; size = sizeof(numcpus); if (sysctl(which, 2, &numcpus, &size, NULL, 0) < 0) { - return -1; + return uv__new_sys_error(errno); } *cpu_infos = (uv_cpu_info_t*)malloc(numcpus * sizeof(uv_cpu_info_t)); @@ -248,11 +255,11 @@ uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { cpu_info = &(*cpu_infos)[i]; - cpu_info->cpu_times.user = (uint64_t)(info[CP_USER]) * multiplier); - cpu_info->cpu_times.nice = ((uint64_t)(info[CP_NICE]) * multiplier); - cpu_info->cpu_times.sys = (uint64_t)(info[CP_SYS]) * multiplier)); - cpu_info->cpu_times.idle = (uint64_t)(info[CP_IDLE]) * multiplier)); - cpu_info->cpu_times.irq = (uint64_t)(info[CP_INTR]) * multiplier)); + cpu_info->cpu_times.user = (uint64_t)(info[CP_USER]) * multiplier; + cpu_info->cpu_times.nice = (uint64_t)(info[CP_NICE]) * multiplier; + cpu_info->cpu_times.sys = (uint64_t)(info[CP_SYS]) * multiplier; + cpu_info->cpu_times.idle = (uint64_t)(info[CP_IDLE]) * multiplier; + cpu_info->cpu_times.irq = (uint64_t)(info[CP_INTR]) * multiplier; cpu_info->model = strdup(model); cpu_info->speed = cpuspeed; @@ -266,7 +273,7 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) { int i; for (i = 0; i < count; i++) { - free(cpu_infos[i].brand); + free(cpu_infos[i].model); } free(cpu_infos); diff --git a/deps/uv/src/unix/process.c b/deps/uv/src/unix/process.c index becf60f..431f4d8 100644 --- a/deps/uv/src/unix/process.c +++ b/deps/uv/src/unix/process.c @@ -31,6 +31,10 @@ #include #ifdef __APPLE__ +# include +#endif + +#if defined(__APPLE__) && !defined(TARGET_OS_IPHONE) # include # define environ (*_NSGetEnviron()) #else diff --git a/deps/uv/src/uv-common.c b/deps/uv/src/uv-common.c index 0d1c363..cb9b6b6 100644 --- a/deps/uv/src/uv-common.c +++ b/deps/uv/src/uv-common.c @@ -101,20 +101,23 @@ const char* uv_strerror(uv_err_t err) { #undef UV_STRERROR_GEN -void uv__set_error(uv_loop_t* loop, uv_err_code code, int sys_error) { +int uv__set_error(uv_loop_t* loop, uv_err_code code, int sys_error) { loop->last_err.code = code; loop->last_err.sys_errno_ = sys_error; + return -1; } -void uv__set_sys_error(uv_loop_t* loop, int sys_error) { +int uv__set_sys_error(uv_loop_t* loop, int sys_error) { loop->last_err.code = uv_translate_sys_error(sys_error); loop->last_err.sys_errno_ = sys_error; + return -1; } -void uv__set_artificial_error(uv_loop_t* loop, uv_err_code code) { +int uv__set_artificial_error(uv_loop_t* loop, uv_err_code code) { loop->last_err = uv__new_artificial_error(code); + return -1; } diff --git a/deps/uv/src/uv-common.h b/deps/uv/src/uv-common.h index bb0aba6..72914ec 100644 --- a/deps/uv/src/uv-common.h +++ b/deps/uv/src/uv-common.h @@ -51,9 +51,9 @@ int uv_ares_handles_empty(uv_loop_t* loop); extern const uv_err_t uv_ok_; uv_err_code uv_translate_sys_error(int sys_errno); -void uv__set_error(uv_loop_t* loop, uv_err_code code, int sys_error); -void uv__set_sys_error(uv_loop_t* loop, int sys_error); -void uv__set_artificial_error(uv_loop_t* loop, uv_err_code code); +int uv__set_error(uv_loop_t* loop, uv_err_code code, int sys_error); +int uv__set_sys_error(uv_loop_t* loop, int sys_error); +int uv__set_artificial_error(uv_loop_t* loop, uv_err_code code); uv_err_t uv__new_sys_error(int sys_error); uv_err_t uv__new_artificial_error(uv_err_code code); diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c index 94da291..9c112b8 100644 --- a/deps/uv/src/win/fs.c +++ b/deps/uv/src/win/fs.c @@ -294,6 +294,7 @@ void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length, OVERLAPPED overlapped, *overlapped_ptr; LARGE_INTEGER offset_; DWORD bytes; + DWORD error; VERIFY_UV_FILE(file, req); @@ -323,7 +324,12 @@ void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length, if (ReadFile(handle, buf, length, &bytes, overlapped_ptr)) { SET_REQ_RESULT(req, bytes); } else { - SET_REQ_WIN32_ERROR(req, GetLastError()); + error = GetLastError(); + if (error == ERROR_HANDLE_EOF) { + SET_REQ_RESULT(req, bytes); + } else { + SET_REQ_WIN32_ERROR(req, error); + } } } diff --git a/deps/uv/src/win/internal.h b/deps/uv/src/win/internal.h index 0dc551d..bd5ec1a 100644 --- a/deps/uv/src/win/internal.h +++ b/deps/uv/src/win/internal.h @@ -337,6 +337,10 @@ int WSAAPI uv_wsarecvfrom_workaround(SOCKET socket, WSABUF* buffers, /* Whether ipv6 is supported */ extern int uv_allow_ipv6; +/* Whether there are any non-IFS LSPs stacked on TCP */ +extern int uv_tcp_non_ifs_lsp_ipv4; +extern int uv_tcp_non_ifs_lsp_ipv6; + /* Ip address used to bind to any port at any interface */ extern struct sockaddr_in uv_addr_ip4_any_; extern struct sockaddr_in6 uv_addr_ip6_any_; diff --git a/deps/uv/src/win/tcp.c b/deps/uv/src/win/tcp.c index f810913..956053c 100644 --- a/deps/uv/src/win/tcp.c +++ b/deps/uv/src/win/tcp.c @@ -81,6 +81,7 @@ static int uv__tcp_keepalive(uv_tcp_t* handle, SOCKET socket, int enable, unsign static int uv_tcp_set_socket(uv_loop_t* loop, uv_tcp_t* handle, SOCKET socket, int imported) { DWORD yes = 1; + int non_ifs_lsp; assert(handle->socket == INVALID_SOCKET); @@ -110,7 +111,10 @@ static int uv_tcp_set_socket(uv_loop_t* loop, uv_tcp_t* handle, } } - if (pSetFileCompletionNotificationModes) { + non_ifs_lsp = (handle->flags & UV_HANDLE_IPV6) ? uv_tcp_non_ifs_lsp_ipv6 : + uv_tcp_non_ifs_lsp_ipv4; + + if (pSetFileCompletionNotificationModes && !non_ifs_lsp) { if (pSetFileCompletionNotificationModes((HANDLE) socket, FILE_SKIP_SET_EVENT_ON_HANDLE | FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) { @@ -1035,6 +1039,10 @@ int uv_tcp_import(uv_tcp_t* tcp, WSAPROTOCOL_INFOW* socket_protocol_info) { tcp->flags |= UV_HANDLE_BOUND; tcp->flags |= UV_HANDLE_SHARED_TCP_SERVER; + if (socket_protocol_info->iAddressFamily == AF_INET6) { + tcp->flags |= UV_HANDLE_IPV6; + } + return uv_tcp_set_socket(tcp->loop, tcp, socket, 1); } diff --git a/deps/uv/src/win/winsock.c b/deps/uv/src/win/winsock.c index 78acba9..667145d 100644 --- a/deps/uv/src/win/winsock.c +++ b/deps/uv/src/win/winsock.c @@ -28,6 +28,10 @@ /* Whether ipv6 is supported */ int uv_allow_ipv6; +/* Whether there are any non-IFS LSPs stacked on TCP */ +int uv_tcp_non_ifs_lsp_ipv4; +int uv_tcp_non_ifs_lsp_ipv6; + /* Ip address used to bind to any port at any interface */ struct sockaddr_in uv_addr_ip4_any_; struct sockaddr_in6 uv_addr_ip6_any_; @@ -80,7 +84,9 @@ void uv_winsock_init() { WSADATA wsa_data; int errorno; - SOCKET dummy6; + SOCKET dummy; + WSAPROTOCOL_INFOW protocol_info; + int opt_len; /* Initialize winsock */ errorno = WSAStartup(MAKEWORD(2, 2), &wsa_data); @@ -92,11 +98,48 @@ void uv_winsock_init() { uv_addr_ip4_any_ = uv_ip4_addr("0.0.0.0", 0); uv_addr_ip6_any_ = uv_ip6_addr("::", 0); - /* Detect IPV6 support */ - dummy6 = socket(AF_INET6, SOCK_STREAM, IPPROTO_IP); - if (dummy6 != INVALID_SOCKET) { + /* Detect non-IFS LSPs */ + dummy = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); + if (dummy == INVALID_SOCKET) { + uv_fatal_error(WSAGetLastError(), "socket"); + } + + opt_len = (int) sizeof protocol_info; + if (!getsockopt(dummy, + SOL_SOCKET, + SO_PROTOCOL_INFOW, + (char*) &protocol_info, + &opt_len) == SOCKET_ERROR) { + uv_fatal_error(WSAGetLastError(), "socket"); + } + + if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)) { + uv_tcp_non_ifs_lsp_ipv4 = 1; + } + + if (closesocket(dummy) == SOCKET_ERROR) { + uv_fatal_error(WSAGetLastError(), "closesocket"); + } + + /* Detect IPV6 support and non-IFS LSPs */ + dummy = socket(AF_INET6, SOCK_STREAM, IPPROTO_IP); + if (dummy != INVALID_SOCKET) { uv_allow_ipv6 = TRUE; - if (closesocket(dummy6) == SOCKET_ERROR) { + + opt_len = (int) sizeof protocol_info; + if (!getsockopt(dummy, + SOL_SOCKET, + SO_PROTOCOL_INFOW, + (char*) &protocol_info, + &opt_len) == SOCKET_ERROR) { + uv_fatal_error(WSAGetLastError(), "socket"); + } + + if (!(protocol_info.dwServiceFlags1 & XP1_IFS_HANDLES)) { + uv_tcp_non_ifs_lsp_ipv6 = 1; + } + + if (closesocket(dummy) == SOCKET_ERROR) { uv_fatal_error(WSAGetLastError(), "closesocket"); } } diff --git a/deps/uv/test/run-tests.c b/deps/uv/test/run-tests.c index a101305..4bc5258 100644 --- a/deps/uv/test/run-tests.c +++ b/deps/uv/test/run-tests.c @@ -131,8 +131,8 @@ static int ipc_helper(int listen_after_write) { uv_pipe_open(&channel, 0); - ASSERT(uv_is_readable(&channel)); - ASSERT(uv_is_writable(&channel)); + ASSERT(uv_is_readable((uv_stream_t*)&channel)); + ASSERT(uv_is_writable((uv_stream_t*)&channel)); r = uv_tcp_init(uv_default_loop(), &tcp_server); ASSERT(r == 0); diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c index af2ebbf..619846d 100644 --- a/deps/uv/test/test-fs.c +++ b/deps/uv/test/test-fs.c @@ -219,6 +219,7 @@ static void close_cb(uv_fs_t* req) { uv_fs_req_cleanup(req); if (close_cb_count == 3) { r = uv_fs_unlink(loop, &unlink_req, "test_file2", unlink_cb); + ASSERT(r == 0); } } @@ -231,6 +232,7 @@ static void ftruncate_cb(uv_fs_t* req) { ftruncate_cb_count++; uv_fs_req_cleanup(req); r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); + ASSERT(r == 0); } @@ -249,6 +251,7 @@ static void read_cb(uv_fs_t* req) { ASSERT(strcmp(buf, "test-bu") == 0); r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); } + ASSERT(r == 0); } @@ -268,6 +271,7 @@ static void open_cb(uv_fs_t* req) { memset(buf, 0, sizeof(buf)); r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, read_cb); + ASSERT(r == 0); } @@ -292,6 +296,7 @@ static void fsync_cb(uv_fs_t* req) { fsync_cb_count++; uv_fs_req_cleanup(req); r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); + ASSERT(r == 0); } @@ -303,6 +308,7 @@ static void fdatasync_cb(uv_fs_t* req) { fdatasync_cb_count++; uv_fs_req_cleanup(req); r = uv_fs_fsync(loop, &fsync_req, open_req1.result, fsync_cb); + ASSERT(r == 0); } @@ -314,6 +320,7 @@ static void write_cb(uv_fs_t* req) { write_cb_count++; uv_fs_req_cleanup(req); r = uv_fs_fdatasync(loop, &fdatasync_req, open_req1.result, fdatasync_cb); + ASSERT(r == 0); } @@ -326,6 +333,7 @@ static void create_cb(uv_fs_t* req) { uv_fs_req_cleanup(req); r = uv_fs_write(loop, &write_req, req->result, test_buf, sizeof(test_buf), -1, write_cb); + ASSERT(r == 0); } diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index 75f3634..89a9445 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -217,7 +217,10 @@ }], [ 'OS=="linux"', { 'include_dirs': [ 'src/ares/config_linux' ], - 'sources': [ 'src/unix/linux.c' ], + 'sources': [ + 'src/unix/linux/core.c', + 'src/unix/linux/inotify.c', + ], 'defines': [ 'EV_CONFIG_H="config_linux.h"', 'EIO_CONFIG_H="config_linux.h"', -- 2.7.4