From ba754524a9f6a729a337803aadd5f1b47af968b9 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Tue, 18 Dec 2012 14:14:38 +0400 Subject: [PATCH] deps: upgrade libuv to b86ed94 --- deps/uv/src/unix/kqueue.c | 8 ++++++-- deps/uv/src/unix/sunos.c | 2 +- deps/uv/src/unix/udp.c | 8 +++----- deps/uv/test/benchmark-getaddrinfo.c | 4 ---- deps/uv/test/benchmark-ping-pongs.c | 4 +--- deps/uv/test/run-tests.c | 18 +++++++++++++----- deps/uv/test/runner-unix.c | 8 ++++++-- deps/uv/test/test-fs-event.c | 31 +++++++++++++++++++++++++++++++ deps/uv/test/test-getaddrinfo.c | 4 ---- deps/uv/test/test-list.h | 2 ++ deps/uv/test/test-ping-pong.c | 7 ++----- 11 files changed, 65 insertions(+), 31 deletions(-) diff --git a/deps/uv/src/unix/kqueue.c b/deps/uv/src/unix/kqueue.c index 73ee696..af9078e 100644 --- a/deps/uv/src/unix/kqueue.c +++ b/deps/uv/src/unix/kqueue.c @@ -197,7 +197,9 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { /* TODO batch up */ struct kevent events[1]; EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); - if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) abort(); + if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) + if (errno != ENOENT) + abort(); } } @@ -208,7 +210,9 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { /* TODO batch up */ struct kevent events[1]; EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0); - if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) abort(); + if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL)) + if (errno != ENOENT) + abort(); } } diff --git a/deps/uv/src/unix/sunos.c b/deps/uv/src/unix/sunos.c index 744fea7..48b1fca 100644 --- a/deps/uv/src/unix/sunos.c +++ b/deps/uv/src/unix/sunos.c @@ -376,7 +376,7 @@ int uv_fs_event_init(uv_loop_t* loop, void uv__fs_event_close(uv_fs_event_t* handle) { - if (handle->fd == PORT_FIRED) { + if (handle->fd == PORT_FIRED || handle->fd == PORT_LOADED) { port_dissociate(handle->loop->fs_fd, PORT_SOURCE_FILE, (uintptr_t)&handle->fo); } handle->fd = PORT_DELETED; diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c index 7a970ba..4b242f6 100644 --- a/deps/uv/src/unix/udp.c +++ b/deps/uv/src/unix/udp.c @@ -446,14 +446,12 @@ static int uv__udp_send(uv_udp_send_t* req, int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) { - memset(handle, 0, sizeof *handle); - uv__handle_init(loop, (uv_handle_t*)handle, UV_UDP); - handle->io_watcher.fd = -1; + handle->alloc_cb = NULL; + handle->recv_cb = NULL; + uv__io_init(&handle->io_watcher, uv__udp_io, -1); ngx_queue_init(&handle->write_queue); ngx_queue_init(&handle->write_completed_queue); - uv__io_init(&handle->io_watcher, uv__udp_io, -1); - return 0; } diff --git a/deps/uv/test/benchmark-getaddrinfo.c b/deps/uv/test/benchmark-getaddrinfo.c index 07dfa87..8ee0c50 100644 --- a/deps/uv/test/benchmark-getaddrinfo.c +++ b/deps/uv/test/benchmark-getaddrinfo.c @@ -21,11 +21,7 @@ #include "uv.h" #include "task.h" - #include -#include -#include /* strlen */ - #define CONCURRENT_CALLS 10 #define TOTAL_CALLS 10000 diff --git a/deps/uv/test/benchmark-ping-pongs.c b/deps/uv/test/benchmark-ping-pongs.c index 4196b42..e1de83d 100644 --- a/deps/uv/test/benchmark-ping-pongs.c +++ b/deps/uv/test/benchmark-ping-pongs.c @@ -24,7 +24,6 @@ #include #include -#include /* strlen */ /* Run the benchmark for this many ms */ #define TIME 5000 @@ -103,8 +102,7 @@ static void pinger_write_ping(pinger_t* pinger) { uv_write_t* req; uv_buf_t buf; - buf.base = (char*)&PING; - buf.len = strlen(PING); + buf = uv_buf_init(PING, sizeof(PING) - 1); req = malloc(sizeof *req); if (uv_write(req, (uv_stream_t*) &pinger->tcp, &buf, 1, pinger_write_cb)) { diff --git a/deps/uv/test/run-tests.c b/deps/uv/test/run-tests.c index d0e64f0..a81c7e5 100644 --- a/deps/uv/test/run-tests.c +++ b/deps/uv/test/run-tests.c @@ -19,6 +19,7 @@ * IN THE SOFTWARE. */ +#include #include #include @@ -99,7 +100,7 @@ static int maybe_run_test(int argc, char **argv) { if (strcmp(argv[1], "spawn_helper3") == 0) { char buffer[256]; - fgets(buffer, sizeof(buffer) - 1, stdin); + ASSERT(buffer == fgets(buffer, sizeof(buffer) - 1, stdin)); buffer[sizeof(buffer) - 1] = '\0'; fputs(buffer, stdout); return 1; @@ -111,13 +112,20 @@ static int maybe_run_test(int argc, char **argv) { } if (strcmp(argv[1], "spawn_helper5") == 0) { - const char* out = "fourth stdio!\n\0"; + const char out[] = "fourth stdio!\n"; #ifdef _WIN32 DWORD bytes; - WriteFile((HANDLE) _get_osfhandle(3), out, strlen(out), &bytes, NULL); + WriteFile((HANDLE) _get_osfhandle(3), out, sizeof(out) - 1, &bytes, NULL); #else - write(3, out, strlen(out)); - fsync(3); + { + ssize_t r; + + do + r = write(3, out, sizeof(out) - 1); + while (r == -1 && errno == EINTR); + + fsync(3); + } #endif return 1; } diff --git a/deps/uv/test/runner-unix.c b/deps/uv/test/runner-unix.c index 77c68dc..f6ea45e 100644 --- a/deps/uv/test/runner-unix.c +++ b/deps/uv/test/runner-unix.c @@ -24,6 +24,7 @@ #include /* uintptr_t */ +#include #include /* usleep */ #include /* strdup */ #include @@ -146,8 +147,11 @@ static void* dowait(void* data) { if (args->pipe[1] >= 0) { /* Write a character to the main thread to notify it about this. */ - char c = 0; - write(args->pipe[1], &c, 1); + ssize_t r; + + do + r = write(args->pipe[1], "", 1); + while (r == -1 && errno == EINTR); } return NULL; diff --git a/deps/uv/test/test-fs-event.c b/deps/uv/test/test-fs-event.c index 67f9421..249af9a 100644 --- a/deps/uv/test/test-fs-event.c +++ b/deps/uv/test/test-fs-event.c @@ -296,6 +296,37 @@ TEST_IMPL(fs_event_watch_file_current_dir) { return 0; } +TEST_IMPL(fs_event_no_callback_after_close) { + uv_loop_t* loop = uv_default_loop(); + int r; + + /* Setup */ + remove("watch_dir/file1"); + remove("watch_dir/"); + create_dir(loop, "watch_dir"); + create_file(loop, "watch_dir/file1"); + + r = uv_fs_event_init(loop, + &fs_event, + "watch_dir/file1", + fs_event_cb_file, + 0); + ASSERT(r != -1); + + uv_close((uv_handle_t*)&fs_event, close_cb); + touch_file(loop, "watch_dir/file1"); + uv_run(loop); + + ASSERT(fs_event_cb_called == 0); + ASSERT(close_cb_called == 1); + + /* Cleanup */ + remove("watch_dir/file1"); + remove("watch_dir/"); + + MAKE_VALGRIND_HAPPY(); + return 0; +} TEST_IMPL(fs_event_no_callback_on_close) { uv_loop_t* loop = uv_default_loop(); diff --git a/deps/uv/test/test-getaddrinfo.c b/deps/uv/test/test-getaddrinfo.c index b88d4b3..6baf676 100644 --- a/deps/uv/test/test-getaddrinfo.c +++ b/deps/uv/test/test-getaddrinfo.c @@ -21,11 +21,7 @@ #include "uv.h" #include "task.h" - #include -#include -#include /* strlen */ - #define CONCURRENT_COUNT 10 diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 82a96a0..9c59a2d 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -177,6 +177,7 @@ TEST_DECLARE (fs_event_watch_dir) TEST_DECLARE (fs_event_watch_file) TEST_DECLARE (fs_event_watch_file_twice) TEST_DECLARE (fs_event_watch_file_current_dir) +TEST_DECLARE (fs_event_no_callback_after_close) TEST_DECLARE (fs_event_no_callback_on_close) TEST_DECLARE (fs_event_immediate_close) TEST_DECLARE (fs_event_close_with_pending_event) @@ -450,6 +451,7 @@ TASK_LIST_START TEST_ENTRY (fs_event_watch_file) TEST_ENTRY (fs_event_watch_file_twice) TEST_ENTRY (fs_event_watch_file_current_dir) + TEST_ENTRY (fs_event_no_callback_after_close) TEST_ENTRY (fs_event_no_callback_on_close) TEST_ENTRY (fs_event_immediate_close) TEST_ENTRY (fs_event_close_with_pending_event) diff --git a/deps/uv/test/test-ping-pong.c b/deps/uv/test/test-ping-pong.c index 1b85fa8..a7b31c7 100644 --- a/deps/uv/test/test-ping-pong.c +++ b/deps/uv/test/test-ping-pong.c @@ -24,7 +24,6 @@ #include #include -#include /* strlen */ static int completed_pingers = 0; @@ -77,11 +76,9 @@ static void pinger_write_ping(pinger_t* pinger) { uv_write_t *req; uv_buf_t buf; - buf.base = (char*)&PING; - buf.len = strlen(PING); - - req = malloc(sizeof(uv_write_t)); + buf = uv_buf_init(PING, sizeof(PING) - 1); + req = malloc(sizeof(*req)); if (uv_write(req, (uv_stream_t*)&pinger->stream.tcp, &buf, 1, pinger_after_write)) { FATAL("uv_write failed"); } -- 2.7.4