From 4a67d8cc0e00d0c7341ae62c2f73d59811c82c85 Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Mon, 14 Apr 2014 10:07:33 -0700 Subject: [PATCH 1/8] build: add vc-set-2012 label --- vcbuild.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/vcbuild.bat b/vcbuild.bat index 81d0b5a8..42b0b947 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -51,6 +51,7 @@ call "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% set GYP_MSVS_VERSION=2013 goto select-target +:vc-set-2012 @rem Look for Visual Studio 2012 if not defined VS110COMNTOOLS goto vc-set-2010 if not exist "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2010 From 6e24ce23b1e7576059f85a608eca13b766458a01 Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Thu, 1 May 2014 09:23:46 -0700 Subject: [PATCH 2/8] 2014.05.02, Version 0.10.27 (Stable) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes since version 0.10.26: * windows: fix console signal handler refcount (Saúl Ibarra Corretgé) * win: always leave crit section in get_proc_title (Fedor Indutny) --- ChangeLog | 9 +++++++++ src/version.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0639b07d..87c5d99b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2014.05.02, Version 0.10.27 (Stable) + +Changes since version 0.10.26: + +* windows: fix console signal handler refcount (Saúl Ibarra Corretgé) + +* win: always leave crit section in get_proc_title (Fedor Indutny) + + 2014.04.07, Version 0.10.26 (Stable), d864907611c25ec986c5e77d4d6d6dee88f26926 Changes since version 0.10.25: diff --git a/src/version.c b/src/version.c index ede5667e..0c35b1b3 100644 --- a/src/version.c +++ b/src/version.c @@ -35,7 +35,7 @@ #define UV_VERSION_MAJOR 0 #define UV_VERSION_MINOR 10 #define UV_VERSION_PATCH 27 -#define UV_VERSION_IS_RELEASE 0 +#define UV_VERSION_IS_RELEASE 1 #define UV_VERSION ((UV_VERSION_MAJOR << 16) | \ From 4f8d4a0135ef4a3ba4b97a2138f9fd07acebb938 Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Thu, 1 May 2014 09:23:46 -0700 Subject: [PATCH 3/8] Now working on v0.10.28 --- ChangeLog | 2 +- src/version.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 87c5d99b..efb0a20b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2014.05.02, Version 0.10.27 (Stable) +2014.05.02, Version 0.10.27 (Stable), 6e24ce23b1e7576059f85a608eca13b766458a01 Changes since version 0.10.26: diff --git a/src/version.c b/src/version.c index 0c35b1b3..ac6f43fe 100644 --- a/src/version.c +++ b/src/version.c @@ -34,8 +34,8 @@ #define UV_VERSION_MAJOR 0 #define UV_VERSION_MINOR 10 -#define UV_VERSION_PATCH 27 -#define UV_VERSION_IS_RELEASE 1 +#define UV_VERSION_PATCH 28 +#define UV_VERSION_IS_RELEASE 0 #define UV_VERSION ((UV_VERSION_MAJOR << 16) | \ From c38e97ee4deee7480ab60dc540f374cb472e02d8 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Fri, 11 Apr 2014 03:42:06 +0400 Subject: [PATCH 4/8] test: fix EPIPE race in spawn_closed_process_io The just created stdin should not be closed by a child process before writing to it, otherwise EPIPE happens. --- test/test-spawn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-spawn.c b/test/test-spawn.c index 3afe0cbc..43da6664 100644 --- a/test/test-spawn.c +++ b/test/test-spawn.c @@ -681,9 +681,9 @@ TEST_IMPL(spawn_closed_process_io) { uv_write_t write_req; uv_buf_t buf; uv_stdio_container_t stdio[2]; - static char buffer[] = "hello-from-spawn_stdin"; + static char buffer[] = "hello-from-spawn_stdin\n"; - init_process_options("spawn_helper1", exit_cb); + init_process_options("spawn_helper3", exit_cb); uv_pipe_init(uv_default_loop(), &in, 0); options.stdio = stdio; From 12bb46c095032b5106ffbd6feb1931917dcdd9d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Mon, 12 May 2014 16:48:52 +0200 Subject: [PATCH 5/8] windows: fix handling closed socket while poll handle is closing fixes #1278 (backport from master for v0.10 branch) --- build.mk | 1 + src/win/poll.c | 3 +- test/test-list.h | 2 + test/test-poll-closesocket.c | 89 ++++++++++++++++++++++++++++++++++++ uv.gyp | 1 + 5 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 test/test-poll-closesocket.c diff --git a/build.mk b/build.mk index e273e251..a2fdac7d 100644 --- a/build.mk +++ b/build.mk @@ -102,6 +102,7 @@ TESTS= \ test/test-platform-output.o \ test/test-poll.o \ test/test-poll-close.o \ + test/test-poll-closesocket.o \ test/test-process-title.o \ test/test-ref.o \ test/test-run-nowait.o \ diff --git a/src/win/poll.c b/src/win/poll.c index f6972f96..76427b01 100644 --- a/src/win/poll.c +++ b/src/win/poll.c @@ -187,7 +187,8 @@ static void uv__fast_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, if (afd_poll_info->Handles[0].Events & AFD_POLL_LOCAL_CLOSE) { /* Stop polling. */ handle->events = 0; - uv__handle_stop(handle); + if (uv__is_active(handle)) + uv__handle_stop(handle); } if (events != 0) { diff --git a/test/test-list.h b/test/test-list.h index c280ca95..7930c1c3 100644 --- a/test/test-list.h +++ b/test/test-list.h @@ -215,6 +215,7 @@ TEST_DECLARE (poll_duplex) TEST_DECLARE (poll_unidirectional) TEST_DECLARE (poll_close) #ifdef _WIN32 +TEST_DECLARE (poll_closesocket) TEST_DECLARE (spawn_detect_pipe_name_collisions_on_windows) TEST_DECLARE (argument_escaping) TEST_DECLARE (environment_creation) @@ -449,6 +450,7 @@ TASK_LIST_START TEST_ENTRY (kill) #ifdef _WIN32 + TEST_ENTRY (poll_closesocket) TEST_ENTRY (spawn_detect_pipe_name_collisions_on_windows) TEST_ENTRY (argument_escaping) TEST_ENTRY (environment_creation) diff --git a/test/test-poll-closesocket.c b/test/test-poll-closesocket.c new file mode 100644 index 00000000..4db74a01 --- /dev/null +++ b/test/test-poll-closesocket.c @@ -0,0 +1,89 @@ +/* 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. + */ + +#ifdef _WIN32 + +#include + +#include "uv.h" +#include "task.h" + +uv_os_sock_t sock; +uv_poll_t handle; + +static int close_cb_called = 0; + + +static void close_cb(uv_handle_t* h) { + close_cb_called++; +} + + +static void poll_cb(uv_poll_t* h, int status, int events) { + int r; + + ASSERT(status == 0); + ASSERT(h == &handle); + + r = uv_poll_start(&handle, UV_READABLE, poll_cb); + ASSERT(r == 0); + + closesocket(sock); + uv_close((uv_handle_t*) &handle, close_cb); + +} + + +TEST_IMPL(poll_closesocket) { + struct WSAData wsa_data; + int r; + unsigned long on; + struct sockaddr_in addr; + + r = WSAStartup(MAKEWORD(2, 2), &wsa_data); + ASSERT(r == 0); + + sock = socket(AF_INET, SOCK_STREAM, 0); + ASSERT(sock != INVALID_SOCKET); + on = 1; + r = ioctlsocket(sock, FIONBIO, &on); + ASSERT(r == 0); + + r = uv_ip4_addr("127.0.0.1", TEST_PORT, &addr); + ASSERT(r == 0); + + r = connect(sock, (const struct sockaddr*) &addr, sizeof addr); + ASSERT(r != 0); + ASSERT(WSAGetLastError() == WSAEWOULDBLOCK); + + r = uv_poll_init_socket(uv_default_loop(), &handle, sock); + ASSERT(r == 0); + r = uv_poll_start(&handle, UV_WRITABLE, poll_cb); + ASSERT(r == 0); + + uv_run(uv_default_loop(), UV_RUN_DEFAULT); + + ASSERT(close_cb_called == 1); + + MAKE_VALGRIND_HAPPY(); + return 0; +} +#endif diff --git a/uv.gyp b/uv.gyp index 4e87dc1a..7cd0f7d4 100644 --- a/uv.gyp +++ b/uv.gyp @@ -322,6 +322,7 @@ 'test/test-platform-output.c', 'test/test-poll.c', 'test/test-poll-close.c', + 'test/test-poll-closesocket.c', 'test/test-process-title.c', 'test/test-ref.c', 'test/test-run-nowait.c', From dd893814ad37d9fc051c9c2db0ca21d45d7b65e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 18 Jun 2014 01:18:55 +0200 Subject: [PATCH 6/8] unix: return system error on EAI_SYSTEM --- src/unix/getaddrinfo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/unix/getaddrinfo.c b/src/unix/getaddrinfo.c index 283d295f..a4b7b3d6 100644 --- a/src/unix/getaddrinfo.c +++ b/src/unix/getaddrinfo.c @@ -34,6 +34,8 @@ static void uv__getaddrinfo_work(struct uv__work* w) { req->service, req->hints, &req->res); + if (req->retcode == EAI_SYSTEM) + req->retcode = -errno; } @@ -67,7 +69,10 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { req->service = NULL; req->hostname = NULL; - if (req->retcode == 0) { + if (req->retcode < 0) { + /* EAI_SYSTEM error */ + uv__set_sys_error(req->loop, -req->result); + } else if (req->retcode == 0) { /* OK */ #if defined(EAI_NODATA) /* FreeBSD deprecated EAI_NODATA */ } else if (req->retcode == EAI_NONAME || req->retcode == EAI_NODATA) { From 58f87691a4077013dc032cd523ab8b0d4595a9e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 19 Jun 2014 09:12:52 +0200 Subject: [PATCH 7/8] unix: fix bogus structure field name --- src/unix/getaddrinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/getaddrinfo.c b/src/unix/getaddrinfo.c index a4b7b3d6..287c9940 100644 --- a/src/unix/getaddrinfo.c +++ b/src/unix/getaddrinfo.c @@ -71,7 +71,7 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { if (req->retcode < 0) { /* EAI_SYSTEM error */ - uv__set_sys_error(req->loop, -req->result); + uv__set_sys_error(req->loop, -req->retcode); } else if (req->retcode == 0) { /* OK */ #if defined(EAI_NODATA) /* FreeBSD deprecated EAI_NODATA */ From 211bf4ec37a73dea06d15233ffa747e9387b8947 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 19 Jun 2014 11:27:24 -0400 Subject: [PATCH 8/8] darwin: invoke `mach_timebase_info` only once According to @aktau, the call to `mach_timebase_info` costs 90% of the total execution time of `uv_hrtime()`. The result of the call is static on all existing platforms, so there is no need in invoking it multiple times. Signed-off-by: Fedor Indutny --- src/unix/darwin.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/unix/darwin.c b/src/unix/darwin.c index 77e662f4..f37d58df 100644 --- a/src/unix/darwin.c +++ b/src/unix/darwin.c @@ -179,12 +179,14 @@ void uv__cf_loop_signal(uv_loop_t* loop, cf_loop_signal_cb cb, void* arg) { uint64_t uv__hrtime(void) { - mach_timebase_info_data_t info; + static mach_timebase_info_data_t info; - if (mach_timebase_info(&info) != KERN_SUCCESS) - abort(); + if ((ACCESS_ONCE(uint32_t, info.numer) == 0 || + ACCESS_ONCE(uint32_t, info.denom) == 0) && + mach_timebase_info(&info) != KERN_SUCCESS) + abort(); - return mach_absolute_time() * info.numer / info.denom; + return mach_absolute_time() * info.numer / info.denom; }