diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2012-01-21 06:13:58 +0400 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-01-21 06:14:15 +0400 |
commit | 08ab306afd0161aebde527a145c49cb848718df2 (patch) | |
tree | 3f5c0664ca0e486de0fd004ef37b837d45712b63 /deps | |
parent | 35fe3eb5c774d1c21fdafb010c633ab6bc42d2c7 (diff) |
uv: upgrade to 497b1ec
Diffstat (limited to 'deps')
-rw-r--r-- | deps/uv/common.gypi | 1 | ||||
-rwxr-xr-x | deps/uv/gyp_uv | 4 | ||||
-rw-r--r-- | deps/uv/include/uv-private/ev.h | 2 | ||||
-rw-r--r-- | deps/uv/include/uv.h | 29 | ||||
-rw-r--r-- | deps/uv/src/unix/core.c | 11 | ||||
-rw-r--r-- | deps/uv/src/unix/ev/ev.c | 6 | ||||
-rw-r--r-- | deps/uv/src/unix/ev/ev_kqueue.c | 2 | ||||
-rw-r--r-- | deps/uv/src/unix/tty.c | 6 | ||||
-rw-r--r-- | deps/uv/src/unix/udp.c | 36 | ||||
-rw-r--r-- | deps/uv/src/win/core.c | 5 | ||||
-rw-r--r-- | deps/uv/test/echo-server.c | 64 | ||||
-rw-r--r-- | deps/uv/test/task.h | 1 | ||||
-rw-r--r-- | deps/uv/test/test-fs-event.c | 18 | ||||
-rw-r--r-- | deps/uv/test/test-list.h | 46 | ||||
-rw-r--r-- | deps/uv/test/test-ref.c | 169 | ||||
-rw-r--r-- | deps/uv/test/test-tcp-close.c | 47 | ||||
-rw-r--r-- | deps/uv/test/test-timer.c | 40 | ||||
-rw-r--r-- | deps/uv/test/test-tty.c | 2 |
18 files changed, 353 insertions, 136 deletions
diff --git a/deps/uv/common.gypi b/deps/uv/common.gypi index e0eb76d267b..0d7ec83dd9b 100644 --- a/deps/uv/common.gypi +++ b/deps/uv/common.gypi @@ -153,7 +153,6 @@ 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden 'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics 'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES', # -Wnewline-eof - 'MACOSX_DEPLOYMENT_TARGET': '10.4', # -mmacosx-version-min=10.4 'PREBINDING': 'NO', # No -Wl,-prebind 'USE_HEADERMAP': 'NO', 'OTHER_CFLAGS': [ diff --git a/deps/uv/gyp_uv b/deps/uv/gyp_uv index a7a9689c265..225c9768db1 100755 --- a/deps/uv/gyp_uv +++ b/deps/uv/gyp_uv @@ -45,12 +45,12 @@ if __name__ == '__main__': # There's a bug with windows which doesn't allow this feature. if sys.platform != 'win32': - # Tell gyp to write the Makefiles into output_dir args.extend(['--generator-output', output_dir]) - # Tell make to write its output into the same dir args.extend(['-Goutput_dir=' + output_dir]) + # Create Makefiles, not XCode projects + args.extend('-f make'.split()) args.append('-Dtarget_arch=ia32') args.append('-Dcomponent=static_library') diff --git a/deps/uv/include/uv-private/ev.h b/deps/uv/include/uv-private/ev.h index 5d2d7a1e37e..11e81cda5e1 100644 --- a/deps/uv/include/uv-private/ev.h +++ b/deps/uv/include/uv-private/ev.h @@ -562,6 +562,8 @@ EV_MAYBE_UNUSED ev_is_default_loop (EV_P) /* create and destroy alternative loops that don't handle signals */ struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0)); +int ev_loop_refcount (EV_P); + ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */ #else diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h index a2007087550..fb4e40ab4cc 100644 --- a/deps/uv/include/uv.h +++ b/deps/uv/include/uv.h @@ -200,6 +200,9 @@ typedef struct uv_work_s uv_work_t; UV_EXTERN uv_loop_t* uv_loop_new(void); UV_EXTERN void uv_loop_delete(uv_loop_t*); +/* This is a debugging tool. It's NOT part of the official API. */ +UV_EXTERN int uv_loop_refcount(const uv_loop_t*); + /* * Returns the default loop. @@ -629,6 +632,32 @@ UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle, uv_membership membership); /* + * Set the multicast ttl + * + * Arguments: + * handle UDP handle. Should have been initialized with + * `uv_udp_init`. + * ttl 1 through 255 + * + * Returns: + * 0 on success, -1 on error. + */ +int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl); + +/* + * Set broadcast on or off + * + * Arguments: + * handle UDP handle. Should have been initialized with + * `uv_udp_init`. + * on 1 for on, 0 for off + * + * Returns: + * 0 on success, -1 on error. + */ +int uv_udp_set_broadcast(uv_udp_t* handle, int on); + +/* * Send data. If the socket has not previously been bound with `uv_udp_bind` * or `uv_udp_bind6`, it is bound to 0.0.0.0 (the "all interfaces" address) * and a random port number. diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c index cf323adc20a..40fb3d95e44 100644 --- a/deps/uv/src/unix/core.c +++ b/deps/uv/src/unix/core.c @@ -63,12 +63,6 @@ void uv__next(EV_P_ ev_idle* watcher, int revents); static void uv__finish_close(uv_handle_t* handle); - -#ifndef __GNUC__ -#define __attribute__(a) -#endif - - void uv_close(uv_handle_t* handle, uv_close_cb close_cb) { uv_udp_t* udp; uv_async_t* async; @@ -181,6 +175,11 @@ void uv_loop_delete(uv_loop_t* loop) { } +int uv_loop_refcount(const uv_loop_t* loop) { + return ev_loop_refcount(loop->ev); +} + + uv_loop_t* uv_default_loop(void) { if (!default_loop_ptr) { default_loop_ptr = &default_loop_struct; diff --git a/deps/uv/src/unix/ev/ev.c b/deps/uv/src/unix/ev/ev.c index a3bec43fbec..b6e190f75f6 100644 --- a/deps/uv/src/unix/ev/ev.c +++ b/deps/uv/src/unix/ev/ev.c @@ -1958,6 +1958,12 @@ ev_loop_new (unsigned int flags) #endif /* multiplicity */ +int +ev_loop_refcount (EV_P) +{ + return activecnt; +} + #if EV_VERIFY static void noinline verify_watcher (EV_P_ W w) diff --git a/deps/uv/src/unix/ev/ev_kqueue.c b/deps/uv/src/unix/ev/ev_kqueue.c index 212ca29ae64..f03cb8083d7 100644 --- a/deps/uv/src/unix/ev/ev_kqueue.c +++ b/deps/uv/src/unix/ev/ev_kqueue.c @@ -200,8 +200,6 @@ kqueue_destroy (EV_P) void inline_size kqueue_fork (EV_P) { - close (backend_fd); - while ((backend_fd = kqueue ()) < 0) ev_syserr ("(libev) kqueue"); diff --git a/deps/uv/src/unix/tty.c b/deps/uv/src/unix/tty.c index de77f5c46ab..18a892168fb 100644 --- a/deps/uv/src/unix/tty.c +++ b/deps/uv/src/unix/tty.c @@ -120,8 +120,7 @@ uv_handle_type uv_guess_handle(uv_file file) { struct stat s; if (file < 0) { - uv__set_sys_error(NULL, EINVAL); /* XXX Need loop? */ - return -1; + return UV_UNKNOWN_HANDLE; } if (isatty(file)) { @@ -129,8 +128,7 @@ uv_handle_type uv_guess_handle(uv_file file) { } if (fstat(file, &s)) { - uv__set_sys_error(NULL, errno); /* XXX Need loop? */ - return -1; + return UV_UNKNOWN_HANDLE; } if (!S_ISSOCK(s.st_mode) && !S_ISFIFO(s.st_mode)) { diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c index cbb37669a24..0ebfe7079cc 100644 --- a/deps/uv/src/unix/udp.c +++ b/deps/uv/src/unix/udp.c @@ -42,6 +42,10 @@ static int uv__udp_send(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[], static void uv__udp_watcher_start(uv_udp_t* handle, ev_io* w) { int flags; + if (ev_is_active(w)) { + return; + } + assert(w == &handle->read_watcher || w == &handle->write_watcher); @@ -51,17 +55,23 @@ static void uv__udp_watcher_start(uv_udp_t* handle, ev_io* w) { ev_set_cb(w, uv__udp_io); ev_io_set(w, handle->fd, flags); ev_io_start(handle->loop->ev, w); + ev_unref(handle->loop->ev); } void uv__udp_watcher_stop(uv_udp_t* handle, ev_io* w) { int flags; + if (!ev_is_active(w)) { + return; + } + assert(w == &handle->read_watcher || w == &handle->write_watcher); flags = (w == &handle->read_watcher ? EV_READ : EV_WRITE); + ev_ref(handle->loop->ev); ev_io_stop(handle->loop->ev, w); ev_io_set(w, -1, flags); ev_set_cb(w, NULL); @@ -324,6 +334,12 @@ static int uv__bind(uv_udp_t* handle, goto out; } + yes = 1; + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes) == -1) { + uv__set_sys_error(handle->loop, errno); + goto out; + } + if (flags & UV_UDP_IPV6ONLY) { #ifdef IPV6_V6ONLY yes = 1; @@ -332,7 +348,7 @@ static int uv__bind(uv_udp_t* handle, goto out; } #else - uv__set_sys_error((uv_handle_t*)handle, ENOTSUP); + uv__set_sys_error(handle->loop, ENOTSUP); goto out; #endif } @@ -493,6 +509,24 @@ int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr, return 0; } +int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl) { + if (setsockopt(handle->fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof ttl) == -1) { + uv__set_sys_error(handle->loop, errno); + return -1; + } + + return 0; +} + +int uv_udp_set_broadcast(uv_udp_t* handle, int on) { + if (setsockopt(handle->fd, SOL_SOCKET, SO_BROADCAST, &on, sizeof on) == -1) { + uv__set_sys_error(handle->loop, errno); + return -1; + } + + return 0; +} + int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name, int* namelen) { diff --git a/deps/uv/src/win/core.c b/deps/uv/src/win/core.c index 72fee1c80bf..b55c3cea48a 100644 --- a/deps/uv/src/win/core.c +++ b/deps/uv/src/win/core.c @@ -116,6 +116,11 @@ void uv_loop_delete(uv_loop_t* loop) { } +int uv_loop_refcount(const uv_loop_t* loop) { + return loop->refs; +} + + void uv_ref(uv_loop_t* loop) { loop->refs++; } diff --git a/deps/uv/test/echo-server.c b/deps/uv/test/echo-server.c index 8b1754410cd..6b0d8972144 100644 --- a/deps/uv/test/echo-server.c +++ b/deps/uv/test/echo-server.c @@ -34,6 +34,7 @@ static uv_loop_t* loop; static int server_closed; static stream_type serverType; static uv_tcp_t tcpServer; +static uv_udp_t udpServer; static uv_pipe_t pipeServer; static uv_handle_t* server; @@ -176,6 +177,34 @@ static void on_server_close(uv_handle_t* handle) { } +static void on_send(uv_udp_send_t* req, int status); + + +static void on_recv(uv_udp_t* handle, + ssize_t nread, + uv_buf_t buf, + struct sockaddr* addr, + unsigned flags) { + uv_udp_send_t* req; + int r; + + ASSERT(nread > 0); + ASSERT(addr->sa_family == AF_INET); + + req = malloc(sizeof(*req)); + ASSERT(req != NULL); + + r = uv_udp_send(req, handle, &buf, 1, *(struct sockaddr_in*)addr, on_send); + ASSERT(r == 0); +} + + +static void on_send(uv_udp_send_t* req, int status) { + ASSERT(status == 0); + free(req); +} + + static int tcp4_echo_start(int port) { struct sockaddr_in addr = uv_ip4_addr("0.0.0.0", port); int r; @@ -242,6 +271,30 @@ static int tcp6_echo_start(int port) { } +static int udp4_echo_start(int port) { + int r; + + server = (uv_handle_t*)&udpServer; + serverType = UDP; + + r = uv_udp_init(loop, &udpServer); + if (r) { + fprintf(stderr, "uv_udp_init: %s\n", + uv_strerror(uv_last_error(loop))); + return 1; + } + + r = uv_udp_recv_start(&udpServer, echo_alloc, on_recv); + if (r) { + fprintf(stderr, "uv_udp_recv_start: %s\n", + uv_strerror(uv_last_error(loop))); + return 1; + } + + return 0; +} + + static int pipe_echo_start(char* pipeName) { int r; @@ -304,3 +357,14 @@ HELPER_IMPL(pipe_echo_server) { uv_run(loop); return 0; } + + +HELPER_IMPL(udp4_echo_server) { + loop = uv_default_loop(); + + if (udp4_echo_start(TEST_PORT)) + return 1; + + uv_run(loop); + return 0; +} diff --git a/deps/uv/test/task.h b/deps/uv/test/task.h index e28b393bb72..b553f862fc7 100644 --- a/deps/uv/test/task.h +++ b/deps/uv/test/task.h @@ -42,6 +42,7 @@ typedef enum { TCP = 0, + UDP, PIPE } stream_type; diff --git a/deps/uv/test/test-fs-event.c b/deps/uv/test/test-fs-event.c index 8b52f67ff36..7f02e68a776 100644 --- a/deps/uv/test/test-fs-event.c +++ b/deps/uv/test/test-fs-event.c @@ -308,21 +308,3 @@ TEST_IMPL(fs_event_immediate_close) { return 0; } - - -TEST_IMPL(fs_event_unref) { - uv_loop_t* loop; - int r; - - loop = uv_default_loop(); - - r = uv_fs_event_init(loop, &fs_event, ".", fs_event_fail, 0); - ASSERT(r == 0); - - uv_unref(loop); - - r = uv_run(loop); - ASSERT(r == 0); - - return 0; -} diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index f6b58a693f1..5ff162301f0 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -25,8 +25,6 @@ TEST_DECLARE (ipc_listen_before_write) TEST_DECLARE (ipc_listen_after_write) TEST_DECLARE (tcp_ping_pong) TEST_DECLARE (tcp_ping_pong_v6) -TEST_DECLARE (tcp_ref) -TEST_DECLARE (tcp_ref2) TEST_DECLARE (pipe_ping_pong) TEST_DECLARE (delayed_accept) TEST_DECLARE (multiple_listen) @@ -63,18 +61,29 @@ TEST_DECLARE (shutdown_eof) TEST_DECLARE (callback_stack) TEST_DECLARE (error_message) TEST_DECLARE (timer) -TEST_DECLARE (timer_ref) -TEST_DECLARE (timer_ref2) TEST_DECLARE (timer_again) TEST_DECLARE (idle_starvation) TEST_DECLARE (loop_handles) +TEST_DECLARE (get_loadavg) TEST_DECLARE (ref) TEST_DECLARE (idle_ref) -TEST_DECLARE (get_loadavg) TEST_DECLARE (async_ref) TEST_DECLARE (prepare_ref) TEST_DECLARE (check_ref) TEST_DECLARE (unref_in_prepare_cb) +TEST_DECLARE (timer_ref) +TEST_DECLARE (timer_ref2) +TEST_DECLARE (fs_event_ref) +TEST_DECLARE (tcp_ref) +TEST_DECLARE (tcp_ref2) +TEST_DECLARE (tcp_ref3) +TEST_DECLARE (udp_ref) +TEST_DECLARE (udp_ref2) +TEST_DECLARE (udp_ref3) +TEST_DECLARE (pipe_ref) +TEST_DECLARE (pipe_ref2) +TEST_DECLARE (pipe_ref3) +TEST_DECLARE (process_ref) TEST_DECLARE (async) TEST_DECLARE (get_currentexe) TEST_DECLARE (cwd_and_chdir) @@ -112,7 +121,6 @@ TEST_DECLARE (fs_event_watch_file) TEST_DECLARE (fs_event_watch_file_current_dir) TEST_DECLARE (fs_event_no_callback_on_close) TEST_DECLARE (fs_event_immediate_close) -TEST_DECLARE (fs_event_unref) TEST_DECLARE (fs_readdir_empty_dir) TEST_DECLARE (fs_readdir_file) TEST_DECLARE (fs_open_dir) @@ -128,6 +136,7 @@ TEST_DECLARE (listen_no_simultaneous_accepts) #endif HELPER_DECLARE (tcp4_echo_server) HELPER_DECLARE (tcp6_echo_server) +HELPER_DECLARE (udp4_echo_server) HELPER_DECLARE (pipe_echo_server) @@ -139,11 +148,6 @@ TASK_LIST_START TEST_ENTRY (ipc_listen_before_write) TEST_ENTRY (ipc_listen_after_write) - TEST_ENTRY (tcp_ref) - - TEST_ENTRY (tcp_ref2) - TEST_HELPER (tcp_ref2, tcp4_echo_server) - TEST_ENTRY (tcp_ping_pong) TEST_HELPER (tcp_ping_pong, tcp4_echo_server) @@ -200,9 +204,6 @@ TASK_LIST_START TEST_ENTRY (error_message) TEST_ENTRY (timer) - TEST_ENTRY (timer_ref) - TEST_ENTRY (timer_ref2) - TEST_ENTRY (timer_again) TEST_ENTRY (idle_starvation) @@ -213,6 +214,22 @@ TASK_LIST_START TEST_ENTRY (prepare_ref) TEST_ENTRY (check_ref) TEST_ENTRY (unref_in_prepare_cb) + TEST_ENTRY (timer_ref) + TEST_ENTRY (timer_ref2) + TEST_ENTRY (fs_event_ref) + TEST_ENTRY (tcp_ref) + TEST_ENTRY (tcp_ref2) + TEST_ENTRY (tcp_ref3) + TEST_HELPER (tcp_ref3, tcp4_echo_server) + TEST_ENTRY (udp_ref) + TEST_ENTRY (udp_ref2) + TEST_ENTRY (udp_ref3) + TEST_HELPER (udp_ref3, udp4_echo_server) + TEST_ENTRY (pipe_ref) + TEST_ENTRY (pipe_ref2) + TEST_ENTRY (pipe_ref3) + TEST_HELPER (pipe_ref3, pipe_echo_server) + TEST_ENTRY (process_ref) TEST_ENTRY (loop_handles) @@ -269,7 +286,6 @@ TASK_LIST_START TEST_ENTRY (fs_event_watch_file_current_dir) TEST_ENTRY (fs_event_no_callback_on_close) TEST_ENTRY (fs_event_immediate_close) - TEST_ENTRY (fs_event_unref) TEST_ENTRY (fs_readdir_empty_dir) TEST_ENTRY (fs_readdir_file) TEST_ENTRY (fs_open_dir) diff --git a/deps/uv/test/test-ref.c b/deps/uv/test/test-ref.c index 0083335fd12..2b8aabbc6f9 100644 --- a/deps/uv/test/test-ref.c +++ b/deps/uv/test/test-ref.c @@ -22,6 +22,14 @@ #include "uv.h" #include "task.h" +#include <stdlib.h> +#include <string.h> + + +static void fail_cb(void) { + FATAL("fail_cb should not have been called"); +} + TEST_IMPL(ref) { uv_run(uv_default_loop()); @@ -83,3 +91,164 @@ TEST_IMPL(unref_in_prepare_cb) { uv_run(uv_default_loop()); return 0; } + + +TEST_IMPL(timer_ref) { + uv_timer_t h; + uv_timer_init(uv_default_loop(), &h); + uv_unref(uv_default_loop()); + uv_run(uv_default_loop()); + return 0; +} + + +TEST_IMPL(timer_ref2) { + uv_timer_t h; + uv_timer_init(uv_default_loop(), &h); + uv_timer_start(&h, (uv_timer_cb) fail_cb, 42, 42); + uv_unref(uv_default_loop()); + uv_run(uv_default_loop()); + return 0; +} + + +TEST_IMPL(fs_event_ref) { + uv_fs_event_t h; + uv_fs_event_init(uv_default_loop(), &h, ".", (uv_fs_event_cb) fail_cb, 0); + uv_unref(uv_default_loop()); + uv_run(uv_default_loop()); + return 0; +} + + +TEST_IMPL(tcp_ref) { + uv_tcp_t h; + uv_tcp_init(uv_default_loop(), &h); + uv_unref(uv_default_loop()); + uv_run(uv_default_loop()); + return 0; +} + + +TEST_IMPL(tcp_ref2) { + uv_tcp_t h; + uv_tcp_init(uv_default_loop(), &h); + uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb); + uv_unref(uv_default_loop()); + uv_run(uv_default_loop()); + return 0; +} + + +TEST_IMPL(tcp_ref3) { + struct sockaddr_in addr = uv_ip4_addr("127.0.0.1", TEST_PORT); + uv_connect_t req; + uv_tcp_t h; + uv_tcp_init(uv_default_loop(), &h); + uv_tcp_connect(&req, &h, addr, (uv_connect_cb)fail_cb); + uv_unref(uv_default_loop()); + uv_unref(uv_default_loop()); /* connect req refs the loop */ + uv_run(uv_default_loop()); + return 0; +} + + +TEST_IMPL(udp_ref) { + uv_udp_t h; + uv_udp_init(uv_default_loop(), &h); + uv_unref(uv_default_loop()); + uv_run(uv_default_loop()); + return 0; +} + + +TEST_IMPL(udp_ref2) { + struct sockaddr_in addr = uv_ip4_addr("127.0.0.1", TEST_PORT); + uv_udp_t h; + uv_udp_init(uv_default_loop(), &h); + uv_udp_bind(&h, addr, 0); + uv_udp_recv_start(&h, (uv_alloc_cb)fail_cb, (uv_udp_recv_cb)fail_cb); + uv_unref(uv_default_loop()); + uv_run(uv_default_loop()); + return 0; +} + + +TEST_IMPL(udp_ref3) { + struct sockaddr_in addr = uv_ip4_addr("127.0.0.1", TEST_PORT); + uv_buf_t buf = uv_buf_init("PING", 4); + uv_udp_send_t req; + uv_udp_t h; + + uv_udp_init(uv_default_loop(), &h); + uv_udp_send(&req, &h, &buf, 1, addr, (uv_udp_send_cb)fail_cb); + uv_unref(uv_default_loop()); + uv_unref(uv_default_loop()); /* send req refs the loop */ + uv_run(uv_default_loop()); + + return 0; +} + + +TEST_IMPL(pipe_ref) { + uv_pipe_t h; + uv_pipe_init(uv_default_loop(), &h, 0); + uv_unref(uv_default_loop()); + uv_run(uv_default_loop()); + return 0; +} + + +TEST_IMPL(pipe_ref2) { + uv_pipe_t h; + uv_pipe_init(uv_default_loop(), &h, 0); + uv_listen((uv_stream_t*)&h, 128, (uv_connection_cb)fail_cb); + uv_unref(uv_default_loop()); + uv_run(uv_default_loop()); + return 0; +} + + +TEST_IMPL(pipe_ref3) { + uv_connect_t req; + uv_pipe_t h; + uv_pipe_init(uv_default_loop(), &h, 0); + uv_pipe_connect(&req, &h, TEST_PIPENAME, (uv_connect_cb)fail_cb); + uv_unref(uv_default_loop()); + uv_unref(uv_default_loop()); /* connect req refs the loop */ + uv_run(uv_default_loop()); + return 0; +} + + +TEST_IMPL(process_ref) { + /* spawn_helper4 blocks indefinitely. */ + char *argv[] = { NULL, "spawn_helper4", NULL }; + uv_process_options_t options; + size_t exepath_size; + char exepath[256]; + uv_process_t h; + int r; + + memset(&options, 0, sizeof(options)); + exepath_size = sizeof(exepath); + + r = uv_exepath(exepath, &exepath_size); + ASSERT(r == 0); + + argv[0] = exepath; + options.file = exepath; + options.args = argv; + options.exit_cb = NULL; + + r = uv_spawn(uv_default_loop(), &h, options); + ASSERT(r == 0); + + uv_unref(uv_default_loop()); + uv_run(uv_default_loop()); + + r = uv_process_kill(&h, /* SIGTERM */ 15); + ASSERT(r == 0); + + return 0; +} diff --git a/deps/uv/test/test-tcp-close.c b/deps/uv/test/test-tcp-close.c index f5dd0a44058..5da8a84f8a2 100644 --- a/deps/uv/test/test-tcp-close.c +++ b/deps/uv/test/test-tcp-close.c @@ -127,50 +127,3 @@ TEST_IMPL(tcp_close) { return 0; } - - -TEST_IMPL(tcp_ref) { - uv_tcp_t never; - int r; - - /* A tcp just initialized should count as one reference. */ - r = uv_tcp_init(uv_default_loop(), &never); - ASSERT(r == 0); - - /* One unref should set the loop ref count to zero. */ - uv_unref(uv_default_loop()); - - /* Therefore this does not block */ - uv_run(uv_default_loop()); - - return 0; -} - - -static void never_cb(uv_connect_t* conn_req, int status) { - FATAL("never_cb should never be called"); -} - - -TEST_IMPL(tcp_ref2) { - uv_tcp_t never; - int r; - - /* A tcp just initialized should count as one reference. */ - r = uv_tcp_init(uv_default_loop(), &never); - ASSERT(r == 0); - - r = uv_tcp_connect(&connect_req, - &never, - uv_ip4_addr("127.0.0.1", TEST_PORT), - never_cb); - ASSERT(r == 0); - - /* One unref should set the loop ref count to zero. */ - uv_unref(uv_default_loop()); - - /* Therefore this does not block */ - uv_run(uv_default_loop()); - - return 0; -} diff --git a/deps/uv/test/test-timer.c b/deps/uv/test/test-timer.c index 87235a51bc7..17bcb84b770 100644 --- a/deps/uv/test/test-timer.c +++ b/deps/uv/test/test-timer.c @@ -130,43 +130,3 @@ TEST_IMPL(timer) { return 0; } - - -TEST_IMPL(timer_ref) { - uv_timer_t never; - int r; - - /* A timer just initialized should count as one reference. */ - r = uv_timer_init(uv_default_loop(), &never); - ASSERT(r == 0); - - /* One unref should set the loop ref count to zero. */ - uv_unref(uv_default_loop()); - - /* Therefore this does not block */ - uv_run(uv_default_loop()); - - return 0; -} - - -TEST_IMPL(timer_ref2) { - uv_timer_t never; - int r; - - /* A timer just initialized should count as one reference. */ - r = uv_timer_init(uv_default_loop(), &never); - ASSERT(r == 0); - - /* We start the timer, this should not effect the ref count. */ - r = uv_timer_start(&never, never_cb, 1000, 1000); - ASSERT(r == 0); - - /* One unref should set the loop ref count to zero. */ - uv_unref(uv_default_loop()); - - /* Therefore this does not block */ - uv_run(uv_default_loop()); - - return 0; -} diff --git a/deps/uv/test/test-tty.c b/deps/uv/test/test-tty.c index d1f6ae6fe68..1e3e1f280c1 100644 --- a/deps/uv/test/test-tty.c +++ b/deps/uv/test/test-tty.c @@ -27,6 +27,8 @@ TEST_IMPL(tty) { uv_tty_t tty; uv_loop_t* loop = uv_default_loop(); + ASSERT(UV_UNKNOWN_HANDLE == uv_guess_handle(-1)); + /* * Not necessarily a problem if this assert goes off. E.G you are piping * this test to a file. 0 == stdin. |