From 9681fcacf0fd477f999a52f6ff4151d4125d49d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Mon, 9 Feb 2015 21:16:26 +0100 Subject: [PATCH] deps: update libuv to 1.4.0 PR-URL: https://github.com/iojs/io.js/pull/773 Reviewed-By: Ben Noordhuis --- deps/uv/ChangeLog | 12 +++ deps/uv/Makefile.am | 1 + deps/uv/configure.ac | 2 +- deps/uv/docs/src/stream.rst | 6 +- deps/uv/include/uv-version.h | 2 +- deps/uv/src/unix/stream.c | 5 +- deps/uv/src/unix/thread.c | 4 +- deps/uv/test/test-list.h | 2 + deps/uv/test/test-pipe-set-non-blocking.c | 99 +++++++++++++++++++++++ deps/uv/test/test-spawn.c | 2 +- deps/uv/uv.gyp | 1 + 11 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 deps/uv/test/test-pipe-set-non-blocking.c diff --git a/deps/uv/ChangeLog b/deps/uv/ChangeLog index 3d14568bed3..de6ecc17f23 100644 --- a/deps/uv/ChangeLog +++ b/deps/uv/ChangeLog @@ -1,3 +1,15 @@ +2015.02.10, Version 1.4.0 (Stable), 19fb8a90648f3763240db004b77ab984264409be + +Changes since version 1.3.0: + +* unix: check Android support for pthread_cond_timedwait_monotonic_np (Leith + Bade) + +* test: use modified path in test (cjihrig) + +* unix: implement uv_stream_set_blocking() (Ben Noordhuis) + + 2015.01.29, Version 1.3.0 (Stable), 165685b2a9a42cf96501d79cd6d48a18aaa16e3b Changes since version 1.2.1: diff --git a/deps/uv/Makefile.am b/deps/uv/Makefile.am index 6c252298dfd..d7557a1b18e 100644 --- a/deps/uv/Makefile.am +++ b/deps/uv/Makefile.am @@ -189,6 +189,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \ test/test-pipe-sendmsg.c \ test/test-pipe-server-close.c \ test/test-pipe-close-stdout-read-stdin.c \ + test/test-pipe-set-non-blocking.c \ test/test-platform-output.c \ test/test-poll-close.c \ test/test-poll-close-doesnt-corrupt-stack.c \ diff --git a/deps/uv/configure.ac b/deps/uv/configure.ac index 0418335a5bc..56c6baedc78 100644 --- a/deps/uv/configure.ac +++ b/deps/uv/configure.ac @@ -13,7 +13,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. AC_PREREQ(2.57) -AC_INIT([libuv], [1.3.0], [https://github.com/libuv/libuv/issues]) +AC_INIT([libuv], [1.4.0], [https://github.com/libuv/libuv/issues]) AC_CONFIG_MACRO_DIR([m4]) m4_include([m4/libuv-extra-automake-flags.m4]) m4_include([m4/as_case.m4]) diff --git a/deps/uv/docs/src/stream.rst b/deps/uv/docs/src/stream.rst index 2c669cf0418..1f6682adc1c 100644 --- a/deps/uv/docs/src/stream.rst +++ b/deps/uv/docs/src/stream.rst @@ -206,12 +206,14 @@ API Relying too much on this API is not recommended. It is likely to change significantly in the future. - Currently this only works on Windows and only for - :c:type:`uv_pipe_t` handles. + Currently only works on Windows for :c:type:`uv_pipe_t` handles. + On UNIX platforms, all :c:type:`uv_stream_t` handles are supported. Also libuv currently makes no ordering guarantee when the blocking mode is changed after write requests have already been submitted. Therefore it is recommended to set the blocking mode immediately after opening or creating the stream. + .. versionchanged:: 1.4.0 UNIX implementation added. + .. seealso:: The :c:type:`uv_handle_t` API functions also apply. diff --git a/deps/uv/include/uv-version.h b/deps/uv/include/uv-version.h index c78c8b7e58b..9dc34a4e09f 100644 --- a/deps/uv/include/uv-version.h +++ b/deps/uv/include/uv-version.h @@ -31,7 +31,7 @@ */ #define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 3 +#define UV_VERSION_MINOR 4 #define UV_VERSION_PATCH 0 #define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_SUFFIX "" diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c index d41a3429a78..bfced40794e 100644 --- a/deps/uv/src/unix/stream.c +++ b/deps/uv/src/unix/stream.c @@ -1573,5 +1573,8 @@ void uv__stream_close(uv_stream_t* handle) { int uv_stream_set_blocking(uv_stream_t* handle, int blocking) { - return UV_ENOSYS; + /* Don't need to check the file descriptor, uv__nonblock() + * will fail with EBADF if it's not valid. + */ + return uv__nonblock(uv__stream_fd(handle), !blocking); } diff --git a/deps/uv/src/unix/thread.c b/deps/uv/src/unix/thread.c index 7a55bd63247..7e85bcc51ff 100644 --- a/deps/uv/src/unix/thread.c +++ b/deps/uv/src/unix/thread.c @@ -330,7 +330,7 @@ int uv_cond_init(uv_cond_t* cond) { if (err) return -err; -#if !defined(__ANDROID__) +#if !(defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)) err = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); if (err) goto error2; @@ -388,7 +388,7 @@ int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) { timeout += uv__hrtime(UV_CLOCK_PRECISE); ts.tv_sec = timeout / NANOSEC; ts.tv_nsec = timeout % NANOSEC; -#if defined(__ANDROID__) +#if defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC) /* * The bionic pthread implementation doesn't support CLOCK_MONOTONIC, * but has this alternative function instead. diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index d00d0f2621d..9eb6a38dcdc 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -167,6 +167,7 @@ TEST_DECLARE (pipe_ref4) #ifndef _WIN32 TEST_DECLARE (pipe_close_stdout_read_stdin) #endif +TEST_DECLARE (pipe_set_non_blocking) TEST_DECLARE (process_ref) TEST_DECLARE (has_ref) TEST_DECLARE (active) @@ -339,6 +340,7 @@ TASK_LIST_START #ifndef _WIN32 TEST_ENTRY (pipe_close_stdout_read_stdin) #endif + TEST_ENTRY (pipe_set_non_blocking) TEST_ENTRY (tty) TEST_ENTRY (stdio_over_pipes) TEST_ENTRY (ip6_pton) diff --git a/deps/uv/test/test-pipe-set-non-blocking.c b/deps/uv/test/test-pipe-set-non-blocking.c new file mode 100644 index 00000000000..5cf2c19e7fb --- /dev/null +++ b/deps/uv/test/test-pipe-set-non-blocking.c @@ -0,0 +1,99 @@ +/* Copyright (c) 2015, Ben Noordhuis + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "uv.h" +#include "task.h" + +#ifdef _WIN32 + +TEST_IMPL(pipe_set_non_blocking) { + RETURN_SKIP("Test not implemented on Windows."); +} + +#else /* !_WIN32 */ + +#include +#include +#include +#include +#include +#include + +struct thread_ctx { + uv_barrier_t barrier; + int fd; +}; + +static void thread_main(void* arg) { + struct thread_ctx* ctx; + char buf[4096]; + ssize_t n; + + ctx = arg; + uv_barrier_wait(&ctx->barrier); + + do + n = read(ctx->fd, buf, sizeof(buf)); + while (n > 0 || (n == -1 && errno == EINTR)); + + ASSERT(n == 0); +} + +TEST_IMPL(pipe_set_non_blocking) { + struct thread_ctx ctx; + uv_pipe_t pipe_handle; + uv_thread_t thread; + size_t nwritten; + char data[4096]; + uv_buf_t buf; + int fd[2]; + int n; + + ASSERT(0 == uv_pipe_init(uv_default_loop(), &pipe_handle, 0)); + ASSERT(0 == socketpair(AF_UNIX, SOCK_STREAM, 0, fd)); + ASSERT(0 == uv_pipe_open(&pipe_handle, fd[0])); + ASSERT(0 == uv_stream_set_blocking((uv_stream_t*) &pipe_handle, 1)); + + ctx.fd = fd[1]; + ASSERT(0 == uv_barrier_init(&ctx.barrier, 2)); + ASSERT(0 == uv_thread_create(&thread, thread_main, &ctx)); + uv_barrier_wait(&ctx.barrier); + + buf.len = sizeof(data); + buf.base = data; + memset(data, '.', sizeof(data)); + + nwritten = 0; + while (nwritten < 10 << 20) { + /* The stream is in blocking mode so uv_try_write() should always succeed + * with the exact number of bytes that we wanted written. + */ + n = uv_try_write((uv_stream_t*) &pipe_handle, &buf, 1); + ASSERT(n == sizeof(data)); + nwritten += n; + } + + uv_close((uv_handle_t*) &pipe_handle, NULL); + ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + + ASSERT(0 == close(fd[1])); /* fd[0] is closed by uv_close(). */ + ASSERT(0 == uv_thread_join(&thread)); + uv_barrier_destroy(&ctx.barrier); + + MAKE_VALGRIND_HAPPY(); + return 0; +} + +#endif /* !_WIN32 */ diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c index d3c0693b683..9b0030029c1 100644 --- a/deps/uv/test/test-spawn.c +++ b/deps/uv/test/test-spawn.c @@ -1015,7 +1015,7 @@ TEST_IMPL(spawn_with_an_odd_path) { char *path = getenv("PATH"); ASSERT(path != NULL); snprintf(newpath, 2048, ";.;%s", path); - SetEnvironmentVariable("PATH", path); + SetEnvironmentVariable("PATH", newpath); init_process_options("", exit_cb); options.file = options.args[0] = "program-that-had-better-not-exist"; diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index d93f66ad6ef..de4a591392b 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -329,6 +329,7 @@ 'test/test-pipe-sendmsg.c', 'test/test-pipe-server-close.c', 'test/test-pipe-close-stdout-read-stdin.c', + 'test/test-pipe-set-non-blocking.c', 'test/test-platform-output.c', 'test/test-poll.c', 'test/test-poll-close.c',