From cbeeea62cf10bbf71636fe03282590050beb1d36 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Tue, 12 Jun 2012 19:52:38 +0200 Subject: [PATCH] Revert "uv: upgrade to b7e150ee" Upgrade wasn't done correctly. This reverts commit b615077bab71db73cf065d6162cae8d6cb84d8d2. --- deps/uv/include/uv-private/ngx-queue.h | 4 +- deps/uv/include/uv-private/uv-unix.h | 11 +-- deps/uv/src/unix/async.c | 95 ++++--------------- deps/uv/src/unix/core.c | 3 - deps/uv/src/unix/cygwin.c | 2 +- deps/uv/src/unix/dl.c | 1 - deps/uv/src/unix/freebsd.c | 2 +- deps/uv/src/unix/internal.h | 8 +- deps/uv/src/unix/linux/core.c | 2 +- deps/uv/src/unix/linux/syscalls.c | 38 -------- deps/uv/src/unix/linux/syscalls.h | 10 +- deps/uv/src/unix/loop.c | 3 - deps/uv/src/unix/netbsd.c | 2 +- deps/uv/src/unix/openbsd.c | 2 +- deps/uv/src/unix/process.c | 29 ++++-- deps/uv/src/unix/stream.c | 2 +- deps/uv/src/unix/sunos.c | 9 +- deps/uv/src/unix/uv-eio.c | 2 - deps/uv/src/win/process.c | 58 +++++------ deps/uv/src/win/timer.c | 6 +- deps/uv/src/win/util.c | 10 -- deps/uv/src/win/winapi.c | 4 - deps/uv/src/win/winapi.h | 2 +- deps/uv/test/benchmark-list.h | 2 - deps/uv/test/benchmark-million-timers.c | 65 ------------- deps/uv/test/benchmark-pound.c | 2 +- deps/uv/test/runner.c | 2 +- deps/uv/test/test-hrtime.c | 33 +++---- deps/uv/test/test-list.h | 2 - .../uv/test/test-tcp-close-while-connecting.c | 80 ---------------- deps/uv/test/test-tcp-shutdown-after-write.c | 14 ++- deps/uv/uv.gyp | 2 - test/pummel/test-exec.js | 18 +--- 33 files changed, 115 insertions(+), 410 deletions(-) delete mode 100644 deps/uv/test/benchmark-million-timers.c delete mode 100644 deps/uv/test/test-tcp-close-while-connecting.c diff --git a/deps/uv/include/uv-private/ngx-queue.h b/deps/uv/include/uv-private/ngx-queue.h index 6fd0071ff0b..7058ce408d8 100644 --- a/deps/uv/include/uv-private/ngx-queue.h +++ b/deps/uv/include/uv-private/ngx-queue.h @@ -100,9 +100,7 @@ struct ngx_queue_s { #define ngx_queue_foreach(q, h) \ - for ((q) = ngx_queue_head(h); \ - (q) != ngx_queue_sentinel(h); \ - (q) = ngx_queue_next(q)) + for ((q) = ngx_queue_head(h); (q) != (h); (q) = ngx_queue_next(q)) #endif /* NGX_QUEUE_H_INCLUDED_ */ diff --git a/deps/uv/include/uv-private/uv-unix.h b/deps/uv/include/uv-private/uv-unix.h index 62bb0aa45e5..3b9619c87a0 100644 --- a/deps/uv/include/uv-private/uv-unix.h +++ b/deps/uv/include/uv-private/uv-unix.h @@ -38,7 +38,6 @@ #include #include -#include #if __sun # include @@ -114,9 +113,6 @@ struct uv__io_s { ngx_queue_t prepare_handles; \ ngx_queue_t check_handles; \ ngx_queue_t idle_handles; \ - ngx_queue_t async_handles; \ - uv__io_t async_watcher; \ - int async_pipefd[2]; \ /* RB_HEAD(uv__timers, uv_timer_s) */ \ struct uv__timers { struct uv_timer_s* rbh_root; } timer_handles; \ uint64_t time; \ @@ -215,10 +211,9 @@ struct uv__io_s { /* UV_ASYNC */ -#define UV_ASYNC_PRIVATE_FIELDS \ - volatile sig_atomic_t pending; \ - uv_async_cb async_cb; \ - ngx_queue_t queue; +#define UV_ASYNC_PRIVATE_FIELDS \ + ev_async async_watcher; \ + uv_async_cb async_cb; /* UV_TIMER */ diff --git a/deps/uv/src/unix/async.c b/deps/uv/src/unix/async.c index f782e158aeb..db9ce18887b 100644 --- a/deps/uv/src/unix/async.c +++ b/deps/uv/src/unix/async.c @@ -21,99 +21,40 @@ #include "uv.h" #include "internal.h" -#include -#include -#include -#include -static int uv__async_init(uv_loop_t* loop); -static void uv__async_io(uv_loop_t* loop, uv__io_t* handle, int events); +static void uv__async(EV_P_ ev_async* w, int revents) { + uv_async_t* async = container_of(w, uv_async_t, async_watcher); + if (async->async_cb) { + async->async_cb(async, 0); + } +} -int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) { - if (uv__async_init(loop)) - return uv__set_sys_error(loop, errno); - uv__handle_init(loop, (uv_handle_t*)handle, UV_ASYNC); +int uv_async_init(uv_loop_t* loop, uv_async_t* async, uv_async_cb async_cb) { + uv__handle_init(loop, (uv_handle_t*)async, UV_ASYNC); loop->counters.async_init++; - handle->async_cb = async_cb; - handle->pending = 0; + ev_async_init(&async->async_watcher, uv__async); + async->async_cb = async_cb; - ngx_queue_insert_tail(&loop->async_handles, &handle->queue); - uv__handle_start(handle); + /* Note: This does not have symmetry with the other libev wrappers. */ + ev_async_start(loop->ev, &async->async_watcher); + uv__handle_unref(async); + uv__handle_start(async); return 0; } -int uv_async_send(uv_async_t* handle) { - int r; - - handle->pending = 1; /* XXX needs a memory barrier? */ - - do - r = write(handle->loop->async_pipefd[1], "x", 1); - while (r == -1 && errno == EINTR); - - if (r == -1 && errno != EAGAIN && errno != EWOULDBLOCK) - return uv__set_sys_error(handle->loop, errno); - +int uv_async_send(uv_async_t* async) { + ev_async_send(async->loop->ev, &async->async_watcher); return 0; } void uv__async_close(uv_async_t* handle) { - ngx_queue_remove(&handle->queue); + ev_async_stop(handle->loop->ev, &handle->async_watcher); + uv__handle_ref(handle); uv__handle_stop(handle); } - - -static int uv__async_init(uv_loop_t* loop) { - if (loop->async_pipefd[0] != -1) - return 0; - - if (uv__make_pipe(loop->async_pipefd, UV__F_NONBLOCK)) - return -1; - - uv__io_init(&loop->async_watcher, - uv__async_io, - loop->async_pipefd[0], - UV__IO_READ); - uv__io_start(loop, &loop->async_watcher); - - return 0; -} - - -static void uv__async_io(uv_loop_t* loop, uv__io_t* handle, int events) { - char buf[1024]; - ngx_queue_t* q; - uv_async_t* h; - ssize_t r; - - while (1) { - r = read(loop->async_pipefd[0], buf, sizeof(buf)); - - if (r == sizeof(buf)) - continue; - - if (r != -1) - break; - - if (errno == EAGAIN || errno == EWOULDBLOCK) - break; - - if (errno == EINTR) - continue; - - abort(); - } - - ngx_queue_foreach(q, &loop->async_handles) { - h = ngx_queue_data(q, uv_async_t, queue); - if (!h->pending) continue; - h->pending = 0; - h->async_cb(h, 0); - } -} diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c index ca74fb321ab..b33a6f74c70 100644 --- a/deps/uv/src/unix/core.c +++ b/deps/uv/src/unix/core.c @@ -233,9 +233,6 @@ static unsigned int uv__poll_timeout(uv_loop_t* loop) { if (!ngx_queue_empty(&loop->idle_handles)) return 0; - if (loop->closing_handles) - return 0; - return uv__next_timeout(loop); } diff --git a/deps/uv/src/unix/cygwin.c b/deps/uv/src/unix/cygwin.c index a99779d4e4c..31b069f9c48 100644 --- a/deps/uv/src/unix/cygwin.c +++ b/deps/uv/src/unix/cygwin.c @@ -29,7 +29,7 @@ #include #undef NANOSEC -#define NANOSEC ((uint64_t) 1e9) +#define NANOSEC 1000000000 uint64_t uv_hrtime() { diff --git a/deps/uv/src/unix/dl.c b/deps/uv/src/unix/dl.c index 01796e3b8d0..9eb6600112d 100644 --- a/deps/uv/src/unix/dl.c +++ b/deps/uv/src/unix/dl.c @@ -31,7 +31,6 @@ static int uv__dlerror(uv_lib_t* lib); int uv_dlopen(const char* filename, uv_lib_t* lib) { - dlerror(); /* Reset error status. */ lib->errmsg = NULL; lib->handle = dlopen(filename, RTLD_LAZY); return uv__dlerror(lib); diff --git a/deps/uv/src/unix/freebsd.c b/deps/uv/src/unix/freebsd.c index d916b0b1267..1e2c1d43601 100644 --- a/deps/uv/src/unix/freebsd.c +++ b/deps/uv/src/unix/freebsd.c @@ -38,7 +38,7 @@ #include #undef NANOSEC -#define NANOSEC ((uint64_t) 1e9) +#define NANOSEC 1000000000 #ifndef CPUSTATES # define CPUSTATES 5U diff --git a/deps/uv/src/unix/internal.h b/deps/uv/src/unix/internal.h index 23f16f7b0ee..8a28b2aa09c 100644 --- a/deps/uv/src/unix/internal.h +++ b/deps/uv/src/unix/internal.h @@ -168,12 +168,8 @@ void uv__timer_close(uv_timer_t* handle); void uv__udp_close(uv_udp_t* handle); void uv__udp_finish_close(uv_udp_t* handle); -#ifdef UV__O_NONBLOCK -# define UV__F_NONBLOCK UV__O_NONBLOCK -#else -# define UV__F_NONBLOCK 1 -#endif - +#define UV__F_IPC (1 << 0) +#define UV__F_NONBLOCK (1 << 1) int uv__make_socketpair(int fds[2], int flags); int uv__make_pipe(int fds[2], int flags); diff --git a/deps/uv/src/unix/linux/core.c b/deps/uv/src/unix/linux/core.c index 34f48a94b9f..bee70269102 100644 --- a/deps/uv/src/unix/linux/core.c +++ b/deps/uv/src/unix/linux/core.c @@ -46,7 +46,7 @@ #endif #undef NANOSEC -#define NANOSEC ((uint64_t) 1e9) +#define NANOSEC 1000000000 /* This is rather annoying: CLOCK_BOOTTIME lives in but we can't * include that file because it conflicts with . We'll just have to diff --git a/deps/uv/src/unix/linux/syscalls.c b/deps/uv/src/unix/linux/syscalls.c index 4a1f8bc07ff..bdf90cf30d1 100644 --- a/deps/uv/src/unix/linux/syscalls.c +++ b/deps/uv/src/unix/linux/syscalls.c @@ -49,26 +49,6 @@ # endif #endif /* __NR_accept4 */ -#ifndef __NR_eventfd -# if __x86_64__ -# define __NR_eventfd 284 -# elif __i386__ -# define __NR_eventfd 323 -# elif __arm__ -# define __NR_eventfd (UV_SYSCALL_BASE + 351) -# endif -#endif /* __NR_eventfd */ - -#ifndef __NR_eventfd2 -# if __x86_64__ -# define __NR_eventfd2 290 -# elif __i386__ -# define __NR_eventfd2 328 -# elif __arm__ -# define __NR_eventfd2 (UV_SYSCALL_BASE + 356) -# endif -#endif /* __NR_eventfd2 */ - #ifndef __NR_inotify_init # if __x86_64__ # define __NR_inotify_init 253 @@ -167,24 +147,6 @@ int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags) { } -int uv__eventfd(unsigned int count) { -#if __NR_eventfd - return syscall(__NR_eventfd, count); -#else - return errno = ENOSYS, -1; -#endif -} - - -int uv__eventfd2(unsigned int count, int flags) { -#if __NR_eventfd2 - return syscall(__NR_eventfd2, count, flags); -#else - return errno = ENOSYS, -1; -#endif -} - - int uv__inotify_init(void) { #if __NR_inotify_init return syscall(__NR_inotify_init); diff --git a/deps/uv/src/unix/linux/syscalls.h b/deps/uv/src/unix/linux/syscalls.h index ec70fd962f9..5d42044a3b8 100644 --- a/deps/uv/src/unix/linux/syscalls.h +++ b/deps/uv/src/unix/linux/syscalls.h @@ -32,16 +32,12 @@ #define UV__O_NONBLOCK 0x800 #define UV__O_CLOEXEC 0x80000 -#define UV__EFD_CLOEXEC UV__O_CLOEXEC -#define UV__EFD_NONBLOCK UV__O_NONBLOCK +#define UV__SOCK_CLOEXEC UV__O_CLOEXEC +#define UV__SOCK_NONBLOCK UV__O_NONBLOCK #define UV__IN_CLOEXEC UV__O_CLOEXEC #define UV__IN_NONBLOCK UV__O_NONBLOCK -#define UV__SOCK_CLOEXEC UV__O_CLOEXEC -#define UV__SOCK_NONBLOCK UV__O_NONBLOCK - -/* inotify flags */ #define UV__IN_ACCESS 0x001 #define UV__IN_MODIFY 0x002 #define UV__IN_ATTRIB 0x004 @@ -69,8 +65,6 @@ struct uv__mmsghdr { }; int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags); -int uv__eventfd(unsigned int count); -int uv__eventfd2(unsigned int count, int flags); int uv__inotify_init(void); int uv__inotify_init1(int flags); int uv__inotify_add_watch(int fd, const char* path, __u32 mask); diff --git a/deps/uv/src/unix/loop.c b/deps/uv/src/unix/loop.c index 75fad43626f..08985d63372 100644 --- a/deps/uv/src/unix/loop.c +++ b/deps/uv/src/unix/loop.c @@ -40,15 +40,12 @@ int uv__loop_init(uv_loop_t* loop, int default_loop) { RB_INIT(&loop->timer_handles); ngx_queue_init(&loop->active_reqs); ngx_queue_init(&loop->idle_handles); - ngx_queue_init(&loop->async_handles); ngx_queue_init(&loop->check_handles); ngx_queue_init(&loop->prepare_handles); ngx_queue_init(&loop->handle_queue); loop->closing_handles = NULL; loop->channel = NULL; loop->time = uv_hrtime() / 1000000; - loop->async_pipefd[0] = -1; - loop->async_pipefd[1] = -1; loop->ev = (default_loop ? ev_default_loop : ev_loop_new)(flags); ev_set_userdata(loop->ev, loop); eio_channel_init(&loop->uv_eio_channel, loop); diff --git a/deps/uv/src/unix/netbsd.c b/deps/uv/src/unix/netbsd.c index a1a7091bbb0..2fedc94a32a 100644 --- a/deps/uv/src/unix/netbsd.c +++ b/deps/uv/src/unix/netbsd.c @@ -32,7 +32,7 @@ #include #undef NANOSEC -#define NANOSEC ((uint64_t) 1e9) +#define NANOSEC 1000000000 uint64_t uv_hrtime(void) { diff --git a/deps/uv/src/unix/openbsd.c b/deps/uv/src/unix/openbsd.c index 865f8e9e6af..ec757a4a975 100644 --- a/deps/uv/src/unix/openbsd.c +++ b/deps/uv/src/unix/openbsd.c @@ -37,7 +37,7 @@ #include #undef NANOSEC -#define NANOSEC ((uint64_t) 1e9) +#define NANOSEC 1000000000 static char *process_title; diff --git a/deps/uv/src/unix/process.c b/deps/uv/src/unix/process.c index 230afe991fc..d3eb998c1b0 100644 --- a/deps/uv/src/unix/process.c +++ b/deps/uv/src/unix/process.c @@ -68,15 +68,25 @@ static void uv__chld(EV_P_ ev_child* watcher, int revents) { int uv__make_socketpair(int fds[2], int flags) { -#if __linux__ - if (socketpair(AF_UNIX, SOCK_STREAM | UV__SOCK_CLOEXEC | flags, 0, fds) == 0) +#ifdef SOCK_NONBLOCK + int fl; + + fl = SOCK_CLOEXEC; + + if (flags & UV__F_NONBLOCK) + fl |= SOCK_NONBLOCK; + + if (socketpair(AF_UNIX, SOCK_STREAM|fl, 0, fds) == 0) return 0; - /* Retry on EINVAL, it means SOCK_CLOEXEC is not supported. - * Anything else is a genuine error. - */ if (errno != EINVAL) return -1; + + /* errno == EINVAL so maybe the kernel headers lied about + * the availability of SOCK_NONBLOCK. This can happen if people + * build libuv against newer kernel headers than the kernel + * they actually run the software on. + */ #endif if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds)) @@ -96,7 +106,14 @@ int uv__make_socketpair(int fds[2], int flags) { int uv__make_pipe(int fds[2], int flags) { #if __linux__ - if (uv__pipe2(fds, flags | UV__O_CLOEXEC) == 0) + int fl; + + fl = UV__O_CLOEXEC; + + if (flags & UV__F_NONBLOCK) + fl |= UV__O_NONBLOCK; + + if (uv__pipe2(fds, fl) == 0) return 0; if (errno != ENOSYS) diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c index 89790eabfd5..602e94889fe 100644 --- a/deps/uv/src/unix/stream.c +++ b/deps/uv/src/unix/stream.c @@ -708,7 +708,7 @@ int uv_shutdown(uv_shutdown_t* req, uv_stream_t* stream, uv_shutdown_cb cb) { stream->flags & UV_STREAM_SHUT || stream->flags & UV_CLOSED || stream->flags & UV_CLOSING) { - uv__set_artificial_error(stream->loop, UV_ENOTCONN); + uv__set_sys_error(stream->loop, EINVAL); return -1; } diff --git a/deps/uv/src/unix/sunos.c b/deps/uv/src/unix/sunos.c index d5867acb6a6..3cf214c04cf 100644 --- a/deps/uv/src/unix/sunos.c +++ b/deps/uv/src/unix/sunos.c @@ -28,7 +28,9 @@ #include #include -#include +#ifdef SUNOS_HAVE_IFADDRS +# include +#endif #include #include @@ -405,7 +407,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 SUNOS_HAVE_IFADDRS + return uv__new_artificial_error(UV_ENOSYS); +#else struct ifaddrs *addrs, *ent; char ip[INET6_ADDRSTRLEN]; uv_interface_address_t* address; @@ -462,6 +466,7 @@ uv_err_t uv_interface_addresses(uv_interface_address_t** addresses, freeifaddrs(addrs); return uv_ok_; +#endif /* SUNOS_HAVE_IFADDRS */ } diff --git a/deps/uv/src/unix/uv-eio.c b/deps/uv/src/unix/uv-eio.c index 0d931b8840d..10dc0a656bd 100644 --- a/deps/uv/src/unix/uv-eio.c +++ b/deps/uv/src/unix/uv-eio.c @@ -95,13 +95,11 @@ void uv_eio_init(uv_loop_t* loop) { &loop->uv_eio_want_poll_notifier, uv_eio_want_poll_notifier_cb); loop->uv_eio_want_poll_notifier.flags |= UV__HANDLE_INTERNAL; - uv__handle_unref(&loop->uv_eio_want_poll_notifier); uv_async_init(loop, &loop->uv_eio_done_poll_notifier, uv_eio_done_poll_notifier_cb); loop->uv_eio_done_poll_notifier.flags |= UV__HANDLE_INTERNAL; - uv__handle_unref(&loop->uv_eio_done_poll_notifier); uv_once(&uv__eio_init_once_guard, uv__eio_init); } diff --git a/deps/uv/src/win/process.c b/deps/uv/src/win/process.c index a2bd33b8795..332ef0f58ab 100644 --- a/deps/uv/src/win/process.c +++ b/deps/uv/src/win/process.c @@ -1320,46 +1320,32 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process, static uv_err_t uv__kill(HANDLE process_handle, int signum) { - switch (signum) { - case SIGTERM: - case SIGKILL: - case SIGINT: { - /* Unconditionally terminate the process. On Windows, killed processes */ - /* normally return 1. */ - DWORD error, status; - - if (TerminateProcess(process_handle, 1)) - return uv_ok_; - - /* If the process already exited before TerminateProcess was called, */ - /* TerminateProcess will fail with ERROR_ACESS_DENIED. */ - error = GetLastError(); - if (error == ERROR_ACCESS_DENIED && - GetExitCodeProcess(process_handle, &status) && - status != STILL_ACTIVE) { - return uv__new_artificial_error(UV_ESRCH); - } + DWORD status; + uv_err_t err; - return uv__new_sys_error(error); + if (signum == SIGTERM || signum == SIGKILL || signum == SIGINT) { + /* Kill the process. On Windows, killed processes normally return 1. */ + if (TerminateProcess(process_handle, 1)) { + err = uv_ok_; + } else { + err = uv__new_sys_error(GetLastError()); } - - case 0: { - /* Health check: is the process still alive? */ - DWORD status; - - if (!GetExitCodeProcess(process_handle, &status)) - return uv__new_sys_error(GetLastError()); - - if (status != STILL_ACTIVE) - return uv__new_artificial_error(UV_ESRCH); - - return uv_ok_; + } else if (signum == 0) { + /* Health check: is the process still alive? */ + if (GetExitCodeProcess(process_handle, &status)) { + if (status == STILL_ACTIVE) { + err = uv_ok_; + } else { + err = uv__new_artificial_error(UV_ESRCH); + } + } else { + err = uv__new_sys_error(GetLastError()); } - - default: - /* Unsupported signal. */ - return uv__new_artificial_error(UV_ENOSYS); + } else { + err = uv__new_artificial_error(UV_ENOSYS); } + + return err; } diff --git a/deps/uv/src/win/timer.c b/deps/uv/src/win/timer.c index 5ddcfca1f3f..69638bc9c1c 100644 --- a/deps/uv/src/win/timer.c +++ b/deps/uv/src/win/timer.c @@ -90,7 +90,6 @@ void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle) { int uv_timer_start(uv_timer_t* handle, uv_timer_cb timer_cb, int64_t timeout, int64_t repeat) { uv_loop_t* loop = handle->loop; - uv_timer_t* old; if (handle->flags & UV_HANDLE_ACTIVE) { RB_REMOVE(uv_timer_tree_s, &loop->timers, handle); @@ -102,8 +101,9 @@ int uv_timer_start(uv_timer_t* handle, uv_timer_cb timer_cb, int64_t timeout, handle->flags |= UV_HANDLE_ACTIVE; uv__handle_start(handle); - old = RB_INSERT(uv_timer_tree_s, &loop->timers, handle); - assert(old == NULL); + if (RB_INSERT(uv_timer_tree_s, &loop->timers, handle) != NULL) { + uv_fatal_error(ERROR_INVALID_DATA, "RB_INSERT"); + } return 0; } diff --git a/deps/uv/src/win/util.c b/deps/uv/src/win/util.c index 4ceae040360..be43d50d20d 100644 --- a/deps/uv/src/win/util.c +++ b/deps/uv/src/win/util.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -774,13 +773,8 @@ uv_err_t uv_interface_addresses(uv_interface_address_t** addresses, for (adapter_address = adapter_addresses; adapter_address != NULL; adapter_address = adapter_address->Next) { - - if (adapter_address->OperStatus != IfOperStatusUp) - continue; - unicast_address = (IP_ADAPTER_UNICAST_ADDRESS_XP*) adapter_address->FirstUnicastAddress; - while (unicast_address) { (*count)++; unicast_address = unicast_address->Next; @@ -798,10 +792,6 @@ uv_err_t uv_interface_addresses(uv_interface_address_t** addresses, for (adapter_address = adapter_addresses; adapter_address != NULL; adapter_address = adapter_address->Next) { - - if (adapter_address->OperStatus != IfOperStatusUp) - continue; - name = NULL; unicast_address = (IP_ADAPTER_UNICAST_ADDRESS_XP*) adapter_address->FirstUnicastAddress; diff --git a/deps/uv/src/win/winapi.c b/deps/uv/src/win/winapi.c index ab5513ab6f5..80c3e521c5b 100644 --- a/deps/uv/src/win/winapi.c +++ b/deps/uv/src/win/winapi.c @@ -25,15 +25,11 @@ #include "internal.h" -/* Ntdll function pointers */ sRtlNtStatusToDosError pRtlNtStatusToDosError; sNtDeviceIoControlFile pNtDeviceIoControlFile; sNtQueryInformationFile pNtQueryInformationFile; sNtSetInformationFile pNtSetInformationFile; sNtQuerySystemInformation pNtQuerySystemInformation; - - -/* Kernel32 function pointers */ sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx; sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes; sCreateSymbolicLinkW pCreateSymbolicLinkW; diff --git a/deps/uv/src/win/winapi.h b/deps/uv/src/win/winapi.h index df1e822b765..2f57e39ba83 100644 --- a/deps/uv/src/win/winapi.h +++ b/deps/uv/src/win/winapi.h @@ -4419,7 +4419,7 @@ typedef VOID (WINAPI* sReleaseSRWLockExclusive) -/* Ntdll function pointers */ +/* Ntapi function pointers */ extern sRtlNtStatusToDosError pRtlNtStatusToDosError; extern sNtDeviceIoControlFile pNtDeviceIoControlFile; extern sNtQueryInformationFile pNtQueryInformationFile; diff --git a/deps/uv/test/benchmark-list.h b/deps/uv/test/benchmark-list.h index 32cd1ba1c16..e4494f1712f 100644 --- a/deps/uv/test/benchmark-list.h +++ b/deps/uv/test/benchmark-list.h @@ -46,7 +46,6 @@ BENCHMARK_DECLARE (gethostbyname) BENCHMARK_DECLARE (getaddrinfo) BENCHMARK_DECLARE (spawn) BENCHMARK_DECLARE (thread_create) -BENCHMARK_DECLARE (million_timers) HELPER_DECLARE (tcp4_blackhole_server) HELPER_DECLARE (tcp_pump_server) HELPER_DECLARE (pipe_pump_server) @@ -107,5 +106,4 @@ TASK_LIST_START BENCHMARK_ENTRY (spawn) BENCHMARK_ENTRY (thread_create) - BENCHMARK_ENTRY (million_timers) TASK_LIST_END diff --git a/deps/uv/test/benchmark-million-timers.c b/deps/uv/test/benchmark-million-timers.c deleted file mode 100644 index ae56b2bc6c4..00000000000 --- a/deps/uv/test/benchmark-million-timers.c +++ /dev/null @@ -1,65 +0,0 @@ -/* 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 "task.h" -#include "uv.h" - -#define NUM_TIMERS (1000 * 1000) - -static int timer_cb_called; - - -static void timer_cb(uv_timer_t* handle, int status) { - timer_cb_called++; -} - - -BENCHMARK_IMPL(million_timers) { - uv_timer_t* timers; - uv_loop_t* loop; - uint64_t before; - uint64_t after; - int timeout; - int i; - - timers = malloc(NUM_TIMERS * sizeof(timers[0])); - ASSERT(timers != NULL); - - loop = uv_default_loop(); - timeout = 0; - - for (i = 0; i < NUM_TIMERS; i++) { - if (i % 1000 == 0) timeout++; - ASSERT(0 == uv_timer_init(loop, timers + i)); - ASSERT(0 == uv_timer_start(timers + i, timer_cb, timeout, 0)); - } - - before = uv_hrtime(); - ASSERT(0 == uv_run(loop)); - after = uv_hrtime(); - - ASSERT(timer_cb_called == NUM_TIMERS); - free(timers); - - LOGF("%.2f seconds\n", (after - before) / 1e9); - - return 0; -} diff --git a/deps/uv/test/benchmark-pound.c b/deps/uv/test/benchmark-pound.c index 5c29a05b31e..1693c31c8ba 100644 --- a/deps/uv/test/benchmark-pound.c +++ b/deps/uv/test/benchmark-pound.c @@ -26,7 +26,7 @@ #define MAX_CONNS 1000 #undef NANOSEC -#define NANOSEC ((uint64_t) 1e9) +#define NANOSEC ((uint64_t)10e8) #undef DEBUG #define DEBUG 0 diff --git a/deps/uv/test/runner.c b/deps/uv/test/runner.c index 214c9a0dd0d..1bda48066a1 100644 --- a/deps/uv/test/runner.c +++ b/deps/uv/test/runner.c @@ -32,7 +32,7 @@ static void log_progress(int total, int passed, int failed, const char* name) { if (total == 0) total = 1; - LOGF("[%% %3d|+ %3d|- %3d]: %s", (int) ((passed + failed) / ((double) total) * 100.0), + LOGF("[%% %3d|+ %3d|- %3d]: %s", (passed + failed) / total * 100, passed, failed, name); } diff --git a/deps/uv/test/test-hrtime.c b/deps/uv/test/test-hrtime.c index 91059f03af3..566e0d2ee02 100644 --- a/deps/uv/test/test-hrtime.c +++ b/deps/uv/test/test-hrtime.c @@ -27,28 +27,25 @@ #endif #ifndef NANOSEC -# define NANOSEC ((uint64_t) 1e9) +# define NANOSEC 1000000000 #endif TEST_IMPL(hrtime) { uint64_t a, b, diff; - int i = 100; - while (i > 0) { - a = uv_hrtime(); - uv_sleep(45); - b = uv_hrtime(); - - diff = b - a; - - /* printf("i= %d diff = %llu\n", i, (unsigned long long int) diff); */ - - /* The windows Sleep() function has only a resolution of 10-20 ms. */ - /* Check that the difference between the two hrtime values is somewhat in */ - /* the range we expect it to be. */ - ASSERT(diff > (uint64_t) 25 * NANOSEC / MILLISEC); - ASSERT(diff < (uint64_t) 60 * NANOSEC / MILLISEC); - --i; - } + + a = uv_hrtime(); + uv_sleep(100); + b = uv_hrtime(); + + diff = b - a; + + printf("diff = %llu\n", (unsigned long long int) diff); + + /* The windows Sleep() function has only a resolution of 10-20 ms. */ + /* Check that the difference between the two hrtime values is somewhat in */ + /* the range we expect it to be. */ + ASSERT(diff > (uint64_t) 80 * NANOSEC / MILLISEC); + ASSERT(diff < (uint64_t) 120 * NANOSEC / MILLISEC); return 0; } diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 9af246dd7ba..b9104d6f8a1 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -51,7 +51,6 @@ TEST_DECLARE (tcp_bind_localhost_ok) TEST_DECLARE (tcp_listen_without_bind) TEST_DECLARE (tcp_connect_error_fault) TEST_DECLARE (tcp_connect_timeout) -TEST_DECLARE (tcp_close_while_connecting) TEST_DECLARE (tcp_close) TEST_DECLARE (tcp_flags) TEST_DECLARE (tcp_write_error) @@ -244,7 +243,6 @@ TASK_LIST_START TEST_ENTRY (tcp_listen_without_bind) TEST_ENTRY (tcp_connect_error_fault) TEST_ENTRY (tcp_connect_timeout) - TEST_ENTRY (tcp_close_while_connecting) TEST_ENTRY (tcp_close) TEST_ENTRY (tcp_flags) TEST_ENTRY (tcp_write_error) diff --git a/deps/uv/test/test-tcp-close-while-connecting.c b/deps/uv/test/test-tcp-close-while-connecting.c deleted file mode 100644 index 93e331d6de5..00000000000 --- a/deps/uv/test/test-tcp-close-while-connecting.c +++ /dev/null @@ -1,80 +0,0 @@ -/* 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 "task.h" - -static uv_timer_t timer1_handle; -static uv_timer_t timer2_handle; -static uv_tcp_t tcp_handle; - -static int connect_cb_called; -static int timer1_cb_called; -static int close_cb_called; - - -static void close_cb(uv_handle_t* handle) { - close_cb_called++; -} - - -static void connect_cb(uv_connect_t* req, int status) { - ASSERT(status == -1); - ASSERT(uv_last_error(req->handle->loop).code == UV_EINTR); - uv_timer_stop(&timer2_handle); - connect_cb_called++; -} - - -static void timer1_cb(uv_timer_t* handle, int status) { - uv_close((uv_handle_t*)handle, close_cb); - uv_close((uv_handle_t*)&tcp_handle, close_cb); - timer1_cb_called++; -} - - -static void timer2_cb(uv_timer_t* handle, int status) { - ASSERT(0 && "should not be called"); -} - - -TEST_IMPL(tcp_close_while_connecting) { - uv_connect_t connect_req; - struct sockaddr_in addr; - uv_loop_t* loop; - - addr = uv_ip4_addr("1.2.3.4", TEST_PORT); - loop = uv_default_loop(); - - ASSERT(0 == uv_tcp_init(loop, &tcp_handle)); - ASSERT(0 == uv_tcp_connect(&connect_req, &tcp_handle, addr, connect_cb)); - ASSERT(0 == uv_timer_init(loop, &timer1_handle)); - ASSERT(0 == uv_timer_start(&timer1_handle, timer1_cb, 50, 0)); - ASSERT(0 == uv_timer_init(loop, &timer2_handle)); - ASSERT(0 == uv_timer_start(&timer2_handle, timer2_cb, 86400 * 1000, 0)); - ASSERT(0 == uv_run(loop)); - - ASSERT(connect_cb_called == 1); - ASSERT(timer1_cb_called == 1); - ASSERT(close_cb_called == 2); - - return 0; -} diff --git a/deps/uv/test/test-tcp-shutdown-after-write.c b/deps/uv/test/test-tcp-shutdown-after-write.c index 219a3b40547..8bf912361a5 100644 --- a/deps/uv/test/test-tcp-shutdown-after-write.c +++ b/deps/uv/test/test-tcp-shutdown-after-write.c @@ -70,18 +70,13 @@ static void timer_cb(uv_timer_t* handle, int status) { } -static void read_cb(uv_stream_t* handle, ssize_t nread, uv_buf_t buf) { -} - - static void connect_cb(uv_connect_t* req, int status) { - int r; - ASSERT(status == 0); connect_cb_called++; +} - r = uv_read_start((uv_stream_t*)&conn, alloc_cb, read_cb); - ASSERT(r == 0); + +static void read_cb(uv_stream_t* handle, ssize_t nread, uv_buf_t buf) { } @@ -118,6 +113,9 @@ TEST_IMPL(tcp_shutdown_after_write) { r = uv_tcp_connect(&connect_req, &conn, addr, connect_cb); ASSERT(r == 0); + r = uv_read_start((uv_stream_t*)&conn, alloc_cb, read_cb); + ASSERT(r == 0); + r = uv_run(loop); ASSERT(r == 0); diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index 5409389c0e8..964933d51e4 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -342,7 +342,6 @@ 'test/test-tcp-bind-error.c', 'test/test-tcp-bind6-error.c', 'test/test-tcp-close.c', - 'test/test-tcp-close-while-connecting.c', 'test/test-tcp-connect-error-after-write.c', 'test/test-tcp-shutdown-after-write.c', 'test/test-tcp-flags.c', @@ -404,7 +403,6 @@ 'test/benchmark-getaddrinfo.c', 'test/benchmark-list.h', 'test/benchmark-loop-count.c', - 'test/benchmark-million-timers.c', 'test/benchmark-ping-pongs.c', 'test/benchmark-pound.c', 'test/benchmark-pump.c', diff --git a/test/pummel/test-exec.js b/test/pummel/test-exec.js index 3b16d020a5b..70771ab4e19 100644 --- a/test/pummel/test-exec.js +++ b/test/pummel/test-exec.js @@ -22,20 +22,10 @@ var common = require('../common'); var assert = require('assert'); var exec = require('child_process').exec; - - -if (process.platform !== 'win32') { - var SLEEP = "sleep 3"; -} else { - var SLEEP = "choice /t 3 /c X /d X"; -} - var success_count = 0; var error_count = 0; - -exec(process.execPath + ' -p -e process.versions', - function(err, stdout, stderr) { +exec('ls /', function(err, stdout, stderr) { if (err) { error_count++; console.log('error!: ' + err.code); @@ -49,7 +39,7 @@ exec(process.execPath + ' -p -e process.versions', }); -exec('thisisnotavalidcommand', function(err, stdout, stderr) { +exec('ls /DOES_NOT_EXIST', function(err, stdout, stderr) { if (err) { error_count++; assert.equal('', stdout); @@ -69,7 +59,7 @@ exec('thisisnotavalidcommand', function(err, stdout, stderr) { var sleeperStart = new Date(); -exec(SLEEP, { timeout: 50 }, function(err, stdout, stderr) { +exec('sleep 3', { timeout: 50 }, function(err, stdout, stderr) { var diff = (new Date()) - sleeperStart; console.log('\'sleep 3\' with timeout 50 took %d ms', diff); assert.ok(diff < 500); @@ -108,13 +98,13 @@ function killMeTwiceCallback(err, stdout, stderr) { } + exec('python -c "print 200000*\'C\'"', {maxBuffer: 1000}, function(err, stdout, stderr) { assert.ok(err); assert.ok(/maxBuffer/.test(err.message)); }); - process.on('exit', function() { assert.equal(1, success_count); assert.equal(1, error_count);