Skip to content

Commit dcff5d5

Browse files
saghulJulien Gilli
authored andcommitted
deps: update libuv to 0.10.36
PR: #9274 PR-URL: nodejs/node-v0.x-archive#9274 Reviewed-By: Julien Gilli <julien.gilli@joyent.com>
1 parent 8bcd0a4 commit dcff5d5

26 files changed

+595
-105
lines changed

deps/uv/AUTHORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,6 @@ Javier Hernández <jhernandez@emergya.com>
132132
Tonis Tiigi <tonistiigi@gmail.com>
133133
Michael Hudson-Doyle <michael.hudson@linaro.org>
134134
Helge Deller <deller@gmx.de>
135+
Logan Rosen <loganrosen@gmail.com>
136+
Kenneth Perry <thothonegan@gmail.com>
137+
Michael Penick <michael.penick@datastax.com>

deps/uv/ChangeLog

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,72 @@
1-
2014.12.10, Version 0.10.30 (Stable)
1+
2015.02.27, Version 0.10.36 (Stable)
2+
3+
Changes since version 0.10.35:
4+
5+
* stream: ignore EINVAL for SO_OOBINLINE on OS X (Fedor Indutny)
6+
7+
8+
2015.02.25, Version 0.10.35 (Stable), 4dc978825d870643bbaa4660f71d22975efba29e
9+
10+
Changes since version 0.10.34:
11+
12+
* stream: use SO_OOBINLINE on OS X (Fedor Indutny)
13+
14+
15+
2015.02.21, Version 0.10.34 (Stable), 37aa4aa9b9712c778d7b249563e868cabfdb8332
16+
17+
Changes since version 0.10.33:
18+
19+
* unix: add atomic-ops.h (Ben Noordhuis)
20+
21+
* unix: fix for uv_async data race (Michael Penick)
22+
23+
* unix: call setgoups before calling setuid/setgid (Saúl Ibarra Corretgé)
24+
25+
26+
2015.01.29, Version 0.10.33 (Stable), 7a2253d33ad8215a26c1b34f1952aee7242dd687
27+
28+
Changes since version 0.10.32:
29+
30+
* linux: fix epoll_pwait() regression with < 2.6.19 (Ben Noordhuis)
31+
32+
* test: back-port uv_loop_configure() test (Ben Noordhuis)
33+
34+
35+
2015.01.06, Version 0.10.32 (Stable), 378de30c59aef5fdb6d130fa5cfcb0a68fce571c
36+
37+
Changes since version 0.10.31:
38+
39+
* linux: fix epoll_pwait() sigmask size calculation (Ben Noordhuis)
40+
41+
42+
2014.12.25, Version 0.10.31 (Stable), 4dbd27e2219069a6daa769fb37f98673b77b4261
43+
44+
Changes since version 0.10.30:
45+
46+
* test: test that closing a poll handle doesn't corrupt the stack (Bert Belder)
47+
48+
* win: fix compilation of tests (Marc Schlaich)
49+
50+
* Revert "win: keep a reference to AFD_POLL_INFO in cancel poll" (Bert Belder)
51+
52+
* win: avoid stack corruption when closing a poll handle (Bert Belder)
53+
54+
* gitignore: ignore Visual Studio files (Marc Schlaich)
55+
56+
* win: set fallback message if FormatMessage fails (Marc Schlaich)
57+
58+
* win: fall back to default language in uv_dlerror (Marc Schlaich)
59+
60+
* test: improve compatibility for dlerror test (Marc Schlaich)
61+
62+
* test: check dlerror is "no error" in no error case (Marc Schlaich)
63+
64+
* build: link against -pthread (Logan Rosen)
65+
66+
* win: scandir use 'ls' for formatting long strings (Kenneth Perry)
67+
68+
69+
2014.12.10, Version 0.10.30 (Stable), 5a63f5e9546dca482eeebc3054139b21f509f21f
270

371
Changes since version 0.10.29:
472

deps/uv/build.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ TESTS= \
9191
test/test-ipc-send-recv.o \
9292
test/test-loop-handles.o \
9393
test/test-loop-stop.o \
94+
test/test-loop-configure.o \
9495
test/test-multiple-listen.o \
9596
test/test-mutexes.o \
9697
test/test-osx-select.o \
@@ -126,6 +127,7 @@ TESTS= \
126127
test/test-tcp-connect-timeout.o \
127128
test/test-tcp-flags.o \
128129
test/test-tcp-open.o \
130+
test/test-tcp-oob.o \
129131
test/test-tcp-read-stop.o \
130132
test/test-tcp-shutdown-after-write.o \
131133
test/test-tcp-unexpected-read.o \

deps/uv/checksparse.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ test/test-tcp-open.c
145145
test/test-tcp-read-stop.c
146146
test/test-tcp-shutdown-after-write.c
147147
test/test-tcp-unexpected-read.c
148+
test/test-tcp-oob.c
148149
test/test-tcp-write-error.c
149150
test/test-tcp-write-to-half-open-connection.c
150151
test/test-tcp-writealot.c

deps/uv/config-unix.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ E=
2222
CSTDFLAG=--std=c89 -pedantic -Wall -Wextra -Wno-unused-parameter
2323
CFLAGS += -g
2424
CPPFLAGS += -I$(SRCDIR)/src
25-
LDFLAGS=-lm
25+
LDFLAGS=-lm -pthread
2626

2727
CPPFLAGS += -D_LARGEFILE_SOURCE
2828
CPPFLAGS += -D_FILE_OFFSET_BITS=64
@@ -186,7 +186,7 @@ src/.buildstamp src/unix/.buildstamp test/.buildstamp:
186186
mkdir -p $(@D)
187187
touch $@
188188

189-
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)
189+
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)
190190
$(CC) $(CSTDFLAG) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
191191

192192
src/%.o src/%.pic.o: src/%.c include/uv.h include/uv-private/uv-unix.h src/.buildstamp

deps/uv/include/uv-private/uv-win.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
474474
/* Used in fast mode */ \
475475
SOCKET peer_socket; \
476476
AFD_POLL_INFO afd_poll_info_1; \
477-
union { \
478-
AFD_POLL_INFO* afd_poll_info_ptr; \
479-
AFD_POLL_INFO afd_poll_info; \
480-
} afd_poll_info_2; \
477+
AFD_POLL_INFO afd_poll_info_2; \
481478
/* Used in fast and slow mode. */ \
482479
uv_req_t poll_req_1; \
483480
uv_req_t poll_req_2; \

deps/uv/src/unix/async.c

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "uv.h"
2626
#include "internal.h"
27+
#include "atomic-ops.h"
2728

2829
#include <errno.h>
2930
#include <assert.h>
@@ -34,7 +35,6 @@
3435
static void uv__async_event(uv_loop_t* loop,
3536
struct uv__async* w,
3637
unsigned int nevents);
37-
static int uv__async_make_pending(int* pending);
3838
static int uv__async_eventfd(void);
3939

4040

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

5555

5656
int uv_async_send(uv_async_t* handle) {
57-
if (uv__async_make_pending(&handle->pending) == 0)
57+
/* Do a cheap read first. */
58+
if (ACCESS_ONCE(int, handle->pending) != 0)
59+
return 0;
60+
61+
if (cmpxchgi(&handle->pending, 0, 1) == 0)
5862
uv__async_send(&handle->loop->async_watcher);
5963

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

7680
ngx_queue_foreach(q, &loop->async_handles) {
7781
h = ngx_queue_data(q, uv_async_t, queue);
78-
if (!h->pending) continue;
79-
h->pending = 0;
80-
h->async_cb(h, 0);
81-
}
82-
}
8382

83+
if (cmpxchgi(&h->pending, 1, 0) == 0)
84+
continue;
8485

85-
static int uv__async_make_pending(int* pending) {
86-
/* Do a cheap read first. */
87-
if (ACCESS_ONCE(int, *pending) != 0)
88-
return 1;
89-
90-
/* Micro-optimization: use atomic memory operations to detect if we've been
91-
* preempted by another thread and don't have to make an expensive syscall.
92-
* This speeds up the heavily contended case by about 1-2% and has little
93-
* if any impact on the non-contended case.
94-
*
95-
* Use XCHG instead of the CMPXCHG that __sync_val_compare_and_swap() emits
96-
* on x86, it's about 4x faster. It probably makes zero difference in the
97-
* grand scheme of things but I'm OCD enough not to let this one pass.
98-
*/
99-
#if defined(__i386__) || defined(__x86_64__)
100-
{
101-
unsigned int val = 1;
102-
__asm__ __volatile__ ("xchgl %0, %1"
103-
: "+r" (val)
104-
: "m" (*pending));
105-
return val != 0;
86+
h->async_cb(h, 0);
10687
}
107-
#elif defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 0)
108-
return __sync_val_compare_and_swap(pending, 0, 1) != 0;
109-
#else
110-
ACCESS_ONCE(int, *pending) = 1;
111-
return 0;
112-
#endif
11388
}
11489

11590

deps/uv/src/unix/atomic-ops.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* Copyright (c) 2013, Ben Noordhuis <info@bnoordhuis.nl>
2+
*
3+
* Permission to use, copy, modify, and/or distribute this software for any
4+
* purpose with or without fee is hereby granted, provided that the above
5+
* copyright notice and this permission notice appear in all copies.
6+
*
7+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14+
*/
15+
16+
#ifndef UV_ATOMIC_OPS_H_
17+
#define UV_ATOMIC_OPS_H_
18+
19+
#include "internal.h" /* UV_UNUSED */
20+
21+
UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval));
22+
UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval));
23+
UV_UNUSED(static void cpu_relax(void));
24+
25+
/* Prefer hand-rolled assembly over the gcc builtins because the latter also
26+
* issue full memory barriers.
27+
*/
28+
UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) {
29+
#if defined(__i386__) || defined(__x86_64__)
30+
int out;
31+
__asm__ __volatile__ ("lock; cmpxchg %2, %1;"
32+
: "=a" (out), "+m" (*(volatile int*) ptr)
33+
: "r" (newval), "0" (oldval)
34+
: "memory");
35+
return out;
36+
#else
37+
return __sync_val_compare_and_swap(ptr, oldval, newval);
38+
#endif
39+
}
40+
41+
UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval)) {
42+
#if defined(__i386__) || defined(__x86_64__)
43+
long out;
44+
__asm__ __volatile__ ("lock; cmpxchg %2, %1;"
45+
: "=a" (out), "+m" (*(volatile long*) ptr)
46+
: "r" (newval), "0" (oldval)
47+
: "memory");
48+
return out;
49+
#else
50+
return __sync_val_compare_and_swap(ptr, oldval, newval);
51+
#endif
52+
}
53+
54+
UV_UNUSED(static void cpu_relax(void)) {
55+
#if defined(__i386__) || defined(__x86_64__)
56+
__asm__ __volatile__ ("rep; nop"); /* a.k.a. PAUSE */
57+
#endif
58+
}
59+
60+
#endif /* UV_ATOMIC_OPS_H_ */

deps/uv/src/unix/internal.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@
6666
} \
6767
while (0)
6868

69+
/* The __clang__ and __INTEL_COMPILER checks are superfluous because they
70+
* define __GNUC__. They are here to convey to you, dear reader, that these
71+
* macros are enabled when compiling with clang or icc.
72+
*/
73+
#if defined(__clang__) || \
74+
defined(__GNUC__) || \
75+
defined(__INTEL_COMPILER) || \
76+
defined(__SUNPRO_C)
77+
# define UV_DESTRUCTOR(declaration) __attribute__((destructor)) declaration
78+
# define UV_UNUSED(declaration) __attribute__((unused)) declaration
79+
#else
80+
# define UV_DESTRUCTOR(declaration) declaration
81+
# define UV_UNUSED(declaration) declaration
82+
#endif
83+
6984
#if defined(__linux__)
7085
# define UV__POLLIN UV__EPOLLIN
7186
# define UV__POLLOUT UV__EPOLLOUT

deps/uv/src/unix/linux-core.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <sys/prctl.h>
3434
#include <sys/sysinfo.h>
3535
#include <unistd.h>
36-
#include <signal.h>
3736
#include <fcntl.h>
3837
#include <time.h>
3938

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

127126

128127
void uv__io_poll(uv_loop_t* loop, int timeout) {
128+
static int no_epoll_pwait;
129+
static int no_epoll_wait;
129130
struct uv__epoll_event events[1024];
130131
struct uv__epoll_event* pe;
131132
struct uv__epoll_event e;
132133
ngx_queue_t* q;
133134
uv__io_t* w;
134-
sigset_t* pset;
135-
sigset_t set;
135+
sigset_t sigset;
136+
uint64_t sigmask;
136137
uint64_t base;
137138
uint64_t diff;
138139
int nevents;
@@ -141,7 +142,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
141142
int fd;
142143
int op;
143144
int i;
144-
static int no_epoll_wait;
145145

146146
if (loop->nfds == 0) {
147147
assert(ngx_queue_empty(&loop->watcher_queue));
@@ -183,35 +183,43 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
183183
w->events = w->pevents;
184184
}
185185

186-
pset = NULL;
186+
sigmask = 0;
187187
if (loop->flags & UV_LOOP_BLOCK_SIGPROF) {
188-
pset = &set;
189-
sigemptyset(pset);
190-
sigaddset(pset, SIGPROF);
188+
sigemptyset(&sigset);
189+
sigaddset(&sigset, SIGPROF);
190+
sigmask |= 1 << (SIGPROF - 1);
191191
}
192192

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

197197
for (;;) {
198-
if (no_epoll_wait || pset != NULL) {
198+
if (sigmask != 0 && no_epoll_pwait != 0)
199+
if (pthread_sigmask(SIG_BLOCK, &sigset, NULL))
200+
abort();
201+
202+
if (sigmask != 0 && no_epoll_pwait == 0) {
199203
nfds = uv__epoll_pwait(loop->backend_fd,
200204
events,
201205
ARRAY_SIZE(events),
202206
timeout,
203-
pset);
207+
sigmask);
208+
if (nfds == -1 && errno == ENOSYS)
209+
no_epoll_pwait = 1;
204210
} else {
205211
nfds = uv__epoll_wait(loop->backend_fd,
206212
events,
207213
ARRAY_SIZE(events),
208214
timeout);
209-
if (nfds == -1 && errno == ENOSYS) {
215+
if (nfds == -1 && errno == ENOSYS)
210216
no_epoll_wait = 1;
211-
continue;
212-
}
213217
}
214218

219+
if (sigmask != 0 && no_epoll_pwait != 0)
220+
if (pthread_sigmask(SIG_UNBLOCK, &sigset, NULL))
221+
abort();
222+
215223
/* Update loop->time unconditionally. It's tempting to skip the update when
216224
* timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the
217225
* operating system didn't reschedule our process while in the syscall.
@@ -224,6 +232,12 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
224232
}
225233

226234
if (nfds == -1) {
235+
if (errno == ENOSYS) {
236+
/* epoll_wait() or epoll_pwait() failed, try the other system call. */
237+
assert(no_epoll_wait == 0 || no_epoll_pwait == 0);
238+
continue;
239+
}
240+
227241
if (errno != EINTR)
228242
abort();
229243

0 commit comments

Comments
 (0)