Skip to content

Commit

Permalink
deps: update libuv to 0.10.36
Browse files Browse the repository at this point in the history
PR: #9274
PR-URL: nodejs/node-v0.x-archive#9274
Reviewed-By: Julien Gilli <[email protected]>
  • Loading branch information
saghul authored and Julien Gilli committed Mar 6, 2015
1 parent 8bcd0a4 commit dcff5d5
Show file tree
Hide file tree
Showing 26 changed files with 595 additions and 105 deletions.
3 changes: 3 additions & 0 deletions deps/uv/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,6 @@ Javier Hernández <[email protected]>
Tonis Tiigi <[email protected]>
Michael Hudson-Doyle <[email protected]>
Helge Deller <[email protected]>
Logan Rosen <[email protected]>
Kenneth Perry <[email protected]>
Michael Penick <[email protected]>
70 changes: 69 additions & 1 deletion deps/uv/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,72 @@
2014.12.10, Version 0.10.30 (Stable)
2015.02.27, Version 0.10.36 (Stable)

Changes since version 0.10.35:

* stream: ignore EINVAL for SO_OOBINLINE on OS X (Fedor Indutny)


2015.02.25, Version 0.10.35 (Stable), 4dc978825d870643bbaa4660f71d22975efba29e

Changes since version 0.10.34:

* stream: use SO_OOBINLINE on OS X (Fedor Indutny)


2015.02.21, Version 0.10.34 (Stable), 37aa4aa9b9712c778d7b249563e868cabfdb8332

Changes since version 0.10.33:

* unix: add atomic-ops.h (Ben Noordhuis)

* unix: fix for uv_async data race (Michael Penick)

* unix: call setgoups before calling setuid/setgid (Saúl Ibarra Corretgé)


2015.01.29, Version 0.10.33 (Stable), 7a2253d33ad8215a26c1b34f1952aee7242dd687

Changes since version 0.10.32:

* linux: fix epoll_pwait() regression with < 2.6.19 (Ben Noordhuis)

* test: back-port uv_loop_configure() test (Ben Noordhuis)


2015.01.06, Version 0.10.32 (Stable), 378de30c59aef5fdb6d130fa5cfcb0a68fce571c

Changes since version 0.10.31:

* linux: fix epoll_pwait() sigmask size calculation (Ben Noordhuis)


2014.12.25, Version 0.10.31 (Stable), 4dbd27e2219069a6daa769fb37f98673b77b4261

Changes since version 0.10.30:

* test: test that closing a poll handle doesn't corrupt the stack (Bert Belder)

* win: fix compilation of tests (Marc Schlaich)

* Revert "win: keep a reference to AFD_POLL_INFO in cancel poll" (Bert Belder)

* win: avoid stack corruption when closing a poll handle (Bert Belder)

* gitignore: ignore Visual Studio files (Marc Schlaich)

* win: set fallback message if FormatMessage fails (Marc Schlaich)

* win: fall back to default language in uv_dlerror (Marc Schlaich)

* test: improve compatibility for dlerror test (Marc Schlaich)

* test: check dlerror is "no error" in no error case (Marc Schlaich)

* build: link against -pthread (Logan Rosen)

* win: scandir use 'ls' for formatting long strings (Kenneth Perry)


2014.12.10, Version 0.10.30 (Stable), 5a63f5e9546dca482eeebc3054139b21f509f21f

Changes since version 0.10.29:

Expand Down
2 changes: 2 additions & 0 deletions deps/uv/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ TESTS= \
test/test-ipc-send-recv.o \
test/test-loop-handles.o \
test/test-loop-stop.o \
test/test-loop-configure.o \
test/test-multiple-listen.o \
test/test-mutexes.o \
test/test-osx-select.o \
Expand Down Expand Up @@ -126,6 +127,7 @@ TESTS= \
test/test-tcp-connect-timeout.o \
test/test-tcp-flags.o \
test/test-tcp-open.o \
test/test-tcp-oob.o \
test/test-tcp-read-stop.o \
test/test-tcp-shutdown-after-write.o \
test/test-tcp-unexpected-read.o \
Expand Down
1 change: 1 addition & 0 deletions deps/uv/checksparse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ test/test-tcp-open.c
test/test-tcp-read-stop.c
test/test-tcp-shutdown-after-write.c
test/test-tcp-unexpected-read.c
test/test-tcp-oob.c
test/test-tcp-write-error.c
test/test-tcp-write-to-half-open-connection.c
test/test-tcp-writealot.c
Expand Down
4 changes: 2 additions & 2 deletions deps/uv/config-unix.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ E=
CSTDFLAG=--std=c89 -pedantic -Wall -Wextra -Wno-unused-parameter
CFLAGS += -g
CPPFLAGS += -I$(SRCDIR)/src
LDFLAGS=-lm
LDFLAGS=-lm -pthread

CPPFLAGS += -D_LARGEFILE_SOURCE
CPPFLAGS += -D_FILE_OFFSET_BITS=64
Expand Down Expand Up @@ -186,7 +186,7 @@ src/.buildstamp src/unix/.buildstamp test/.buildstamp:
mkdir -p $(@D)
touch $@

src/unix/%.o src/unix/%.pic.o: src/unix/%.c include/uv.h include/uv-private/uv-unix.h src/unix/internal.h src/unix/.buildstamp $(DTRACE_HEADER)
src/unix/%.o src/unix/%.pic.o: src/unix/%.c include/uv.h include/uv-private/uv-unix.h src/unix/atomic-ops.h src/unix/internal.h src/unix/.buildstamp $(DTRACE_HEADER)
$(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@

src/%.o src/%.pic.o: src/%.c include/uv.h include/uv-private/uv-unix.h src/.buildstamp
Expand Down
5 changes: 1 addition & 4 deletions deps/uv/include/uv-private/uv-win.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
/* Used in fast mode */ \
SOCKET peer_socket; \
AFD_POLL_INFO afd_poll_info_1; \
union { \
AFD_POLL_INFO* afd_poll_info_ptr; \
AFD_POLL_INFO afd_poll_info; \
} afd_poll_info_2; \
AFD_POLL_INFO afd_poll_info_2; \
/* Used in fast and slow mode. */ \
uv_req_t poll_req_1; \
uv_req_t poll_req_2; \
Expand Down
43 changes: 9 additions & 34 deletions deps/uv/src/unix/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "uv.h"
#include "internal.h"
#include "atomic-ops.h"

#include <errno.h>
#include <assert.h>
Expand All @@ -34,7 +35,6 @@
static void uv__async_event(uv_loop_t* loop,
struct uv__async* w,
unsigned int nevents);
static int uv__async_make_pending(int* pending);
static int uv__async_eventfd(void);


Expand All @@ -54,7 +54,11 @@ int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) {


int uv_async_send(uv_async_t* handle) {
if (uv__async_make_pending(&handle->pending) == 0)
/* Do a cheap read first. */
if (ACCESS_ONCE(int, handle->pending) != 0)
return 0;

if (cmpxchgi(&handle->pending, 0, 1) == 0)
uv__async_send(&handle->loop->async_watcher);

return 0;
Expand All @@ -75,41 +79,12 @@ static void uv__async_event(uv_loop_t* loop,

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);
}
}

if (cmpxchgi(&h->pending, 1, 0) == 0)
continue;

static int uv__async_make_pending(int* pending) {
/* Do a cheap read first. */
if (ACCESS_ONCE(int, *pending) != 0)
return 1;

/* Micro-optimization: use atomic memory operations to detect if we've been
* preempted by another thread and don't have to make an expensive syscall.
* This speeds up the heavily contended case by about 1-2% and has little
* if any impact on the non-contended case.
*
* Use XCHG instead of the CMPXCHG that __sync_val_compare_and_swap() emits
* on x86, it's about 4x faster. It probably makes zero difference in the
* grand scheme of things but I'm OCD enough not to let this one pass.
*/
#if defined(__i386__) || defined(__x86_64__)
{
unsigned int val = 1;
__asm__ __volatile__ ("xchgl %0, %1"
: "+r" (val)
: "m" (*pending));
return val != 0;
h->async_cb(h, 0);
}
#elif defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 0)
return __sync_val_compare_and_swap(pending, 0, 1) != 0;
#else
ACCESS_ONCE(int, *pending) = 1;
return 0;
#endif
}


Expand Down
60 changes: 60 additions & 0 deletions deps/uv/src/unix/atomic-ops.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* Copyright (c) 2013, Ben Noordhuis <[email protected]>
*
* 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.
*/

#ifndef UV_ATOMIC_OPS_H_
#define UV_ATOMIC_OPS_H_

#include "internal.h" /* UV_UNUSED */

UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval));
UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval));
UV_UNUSED(static void cpu_relax(void));

/* Prefer hand-rolled assembly over the gcc builtins because the latter also
* issue full memory barriers.
*/
UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) {
#if defined(__i386__) || defined(__x86_64__)
int out;
__asm__ __volatile__ ("lock; cmpxchg %2, %1;"
: "=a" (out), "+m" (*(volatile int*) ptr)
: "r" (newval), "0" (oldval)
: "memory");
return out;
#else
return __sync_val_compare_and_swap(ptr, oldval, newval);
#endif
}

UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval)) {
#if defined(__i386__) || defined(__x86_64__)
long out;
__asm__ __volatile__ ("lock; cmpxchg %2, %1;"
: "=a" (out), "+m" (*(volatile long*) ptr)
: "r" (newval), "0" (oldval)
: "memory");
return out;
#else
return __sync_val_compare_and_swap(ptr, oldval, newval);
#endif
}

UV_UNUSED(static void cpu_relax(void)) {
#if defined(__i386__) || defined(__x86_64__)
__asm__ __volatile__ ("rep; nop"); /* a.k.a. PAUSE */
#endif
}

#endif /* UV_ATOMIC_OPS_H_ */
15 changes: 15 additions & 0 deletions deps/uv/src/unix/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@
} \
while (0)

/* The __clang__ and __INTEL_COMPILER checks are superfluous because they
* define __GNUC__. They are here to convey to you, dear reader, that these
* macros are enabled when compiling with clang or icc.
*/
#if defined(__clang__) || \
defined(__GNUC__) || \
defined(__INTEL_COMPILER) || \
defined(__SUNPRO_C)
# define UV_DESTRUCTOR(declaration) __attribute__((destructor)) declaration
# define UV_UNUSED(declaration) __attribute__((unused)) declaration
#else
# define UV_DESTRUCTOR(declaration) declaration
# define UV_UNUSED(declaration) declaration
#endif

#if defined(__linux__)
# define UV__POLLIN UV__EPOLLIN
# define UV__POLLOUT UV__EPOLLOUT
Expand Down
40 changes: 27 additions & 13 deletions deps/uv/src/unix/linux-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <sys/prctl.h>
#include <sys/sysinfo.h>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <time.h>

Expand Down Expand Up @@ -126,13 +125,15 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {


void uv__io_poll(uv_loop_t* loop, int timeout) {
static int no_epoll_pwait;
static int no_epoll_wait;
struct uv__epoll_event events[1024];
struct uv__epoll_event* pe;
struct uv__epoll_event e;
ngx_queue_t* q;
uv__io_t* w;
sigset_t* pset;
sigset_t set;
sigset_t sigset;
uint64_t sigmask;
uint64_t base;
uint64_t diff;
int nevents;
Expand All @@ -141,7 +142,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
int fd;
int op;
int i;
static int no_epoll_wait;

if (loop->nfds == 0) {
assert(ngx_queue_empty(&loop->watcher_queue));
Expand Down Expand Up @@ -183,35 +183,43 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
w->events = w->pevents;
}

pset = NULL;
sigmask = 0;
if (loop->flags & UV_LOOP_BLOCK_SIGPROF) {
pset = &set;
sigemptyset(pset);
sigaddset(pset, SIGPROF);
sigemptyset(&sigset);
sigaddset(&sigset, SIGPROF);
sigmask |= 1 << (SIGPROF - 1);
}

assert(timeout >= -1);
base = loop->time;
count = 48; /* Benchmarks suggest this gives the best throughput. */

for (;;) {
if (no_epoll_wait || pset != NULL) {
if (sigmask != 0 && no_epoll_pwait != 0)
if (pthread_sigmask(SIG_BLOCK, &sigset, NULL))
abort();

if (sigmask != 0 && no_epoll_pwait == 0) {
nfds = uv__epoll_pwait(loop->backend_fd,
events,
ARRAY_SIZE(events),
timeout,
pset);
sigmask);
if (nfds == -1 && errno == ENOSYS)
no_epoll_pwait = 1;
} else {
nfds = uv__epoll_wait(loop->backend_fd,
events,
ARRAY_SIZE(events),
timeout);
if (nfds == -1 && errno == ENOSYS) {
if (nfds == -1 && errno == ENOSYS)
no_epoll_wait = 1;
continue;
}
}

if (sigmask != 0 && no_epoll_pwait != 0)
if (pthread_sigmask(SIG_UNBLOCK, &sigset, NULL))
abort();

/* Update loop->time unconditionally. It's tempting to skip the update when
* timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the
* operating system didn't reschedule our process while in the syscall.
Expand All @@ -224,6 +232,12 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
}

if (nfds == -1) {
if (errno == ENOSYS) {
/* epoll_wait() or epoll_pwait() failed, try the other system call. */
assert(no_epoll_wait == 0 || no_epoll_pwait == 0);
continue;
}

if (errno != EINTR)
abort();

Expand Down
Loading

0 comments on commit dcff5d5

Please sign in to comment.