Skip to content

Commit 3544386

Browse files
committed
uv: Update to v0.10.29
1 parent 1349b68 commit 3544386

10 files changed

Lines changed: 160 additions & 44 deletions

File tree

deps/uv/AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,4 @@ David Capello <davidcapello@gmail.com>
130130
Paul Tan <pyokagan@gmail.com>
131131
Javier Hernández <jhernandez@emergya.com>
132132
Tonis Tiigi <tonistiigi@gmail.com>
133+
Michael Hudson-Doyle <michael.hudson@linaro.org>

deps/uv/ChangeLog

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
2014.07.32, Version 0.10.28 (Stable)
1+
2014.10.21, Version 0.10.29 (Stable)
2+
3+
Changes since version 0.10.28:
4+
5+
* darwin: allocate enough space for select() hack (Fedor Indutny)
6+
7+
* linux: try epoll_pwait if epoll_wait is missing (Michael Hudson-Doyle)
8+
9+
* windows: map ERROR_INVALID_DRIVE to UV_ENOENT (Saúl Ibarra Corretgé)
10+
11+
12+
2014.07.32, Version 0.10.28 (Stable), 9c14b616f5fb84bfd7d45707bab4bbb85894443e
213

314
Changes since version 0.10.27:
415

deps/uv/config-unix.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ ifeq (__clang__,$(shell sh -c "$(CC) -dM -E - </dev/null | grep -ow __clang__"))
8585
CFLAGS += -Wno-dollar-in-identifier-extension
8686
endif
8787
CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1
88+
CPPFLAGS += -D_DARWIN_UNLIMITED_SELECT=1
8889
LDFLAGS += -framework Foundation \
8990
-framework CoreServices \
9091
-framework ApplicationServices

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
138138
int fd;
139139
int op;
140140
int i;
141+
static int no_epoll_wait;
141142

142143
if (loop->nfds == 0) {
143144
assert(ngx_queue_empty(&loop->watcher_queue));
@@ -184,10 +185,22 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
184185
count = 48; /* Benchmarks suggest this gives the best throughput. */
185186

186187
for (;;) {
187-
nfds = uv__epoll_wait(loop->backend_fd,
188-
events,
189-
ARRAY_SIZE(events),
190-
timeout);
188+
if (!no_epoll_wait) {
189+
nfds = uv__epoll_wait(loop->backend_fd,
190+
events,
191+
ARRAY_SIZE(events),
192+
timeout);
193+
if (nfds == -1 && errno == ENOSYS) {
194+
no_epoll_wait = 1;
195+
continue;
196+
}
197+
} else {
198+
nfds = uv__epoll_pwait(loop->backend_fd,
199+
events,
200+
ARRAY_SIZE(events),
201+
timeout,
202+
NULL);
203+
}
191204

192205
/* Update loop->time unconditionally. It's tempting to skip the update when
193206
* timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the

deps/uv/src/unix/stream.c

Lines changed: 77 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ struct uv__stream_select_s {
5353
int fake_fd;
5454
int int_fd;
5555
int fd;
56+
fd_set* sread;
57+
size_t sread_sz;
58+
fd_set* swrite;
59+
size_t swrite_sz;
5660
};
5761
#endif /* defined(__APPLE__) */
5862

@@ -131,8 +135,6 @@ static void uv__stream_osx_select(void* arg) {
131135
uv_stream_t* stream;
132136
uv__stream_select_t* s;
133137
char buf[1024];
134-
fd_set sread;
135-
fd_set swrite;
136138
int events;
137139
int fd;
138140
int r;
@@ -153,17 +155,17 @@ static void uv__stream_osx_select(void* arg) {
153155
break;
154156

155157
/* Watch fd using select(2) */
156-
FD_ZERO(&sread);
157-
FD_ZERO(&swrite);
158+
memset(s->sread, 0, s->sread_sz);
159+
memset(s->swrite, 0, s->swrite_sz);
158160

159161
if (uv_is_readable(stream))
160-
FD_SET(fd, &sread);
162+
FD_SET(fd, s->sread);
161163
if (uv_is_writable(stream))
162-
FD_SET(fd, &swrite);
163-
FD_SET(s->int_fd, &sread);
164+
FD_SET(fd, s->swrite);
165+
FD_SET(s->int_fd, s->sread);
164166

165167
/* Wait indefinitely for fd events */
166-
r = select(max_fd + 1, &sread, &swrite, NULL, NULL);
168+
r = select(max_fd + 1, s->sread, s->swrite, NULL, NULL);
167169
if (r == -1) {
168170
if (errno == EINTR)
169171
continue;
@@ -177,7 +179,7 @@ static void uv__stream_osx_select(void* arg) {
177179
continue;
178180

179181
/* Empty socketpair's buffer in case of interruption */
180-
if (FD_ISSET(s->int_fd, &sread))
182+
if (FD_ISSET(s->int_fd, s->sread))
181183
while (1) {
182184
r = read(s->int_fd, buf, sizeof(buf));
183185

@@ -198,12 +200,12 @@ static void uv__stream_osx_select(void* arg) {
198200

199201
/* Handle events */
200202
events = 0;
201-
if (FD_ISSET(fd, &sread))
203+
if (FD_ISSET(fd, s->sread))
202204
events |= UV__POLLIN;
203-
if (FD_ISSET(fd, &swrite))
205+
if (FD_ISSET(fd, s->swrite))
204206
events |= UV__POLLOUT;
205207

206-
assert(events != 0 || FD_ISSET(s->int_fd, &sread));
208+
assert(events != 0 || FD_ISSET(s->int_fd, s->sread));
207209
if (events != 0) {
208210
ACCESS_ONCE(int, s->events) = events;
209211

@@ -283,6 +285,10 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) {
283285
int ret;
284286
int kq;
285287
int old_fd;
288+
int max_fd;
289+
size_t sread_sz;
290+
size_t swrite_sz;
291+
int err;
286292

287293
kq = kqueue();
288294
if (kq == -1) {
@@ -306,30 +312,52 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) {
306312
return 0;
307313

308314
/* At this point we definitely know that this fd won't work with kqueue */
309-
s = malloc(sizeof(*s));
310-
if (s == NULL)
311-
return uv__set_artificial_error(stream->loop, UV_ENOMEM);
315+
316+
/*
317+
* Create fds for io watcher and to interrupt the select() loop.
318+
* NOTE: do it ahead of malloc below to allocate enough space for fd_sets
319+
*/
320+
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds))
321+
return uv__set_sys_error(stream->loop, errno);
322+
323+
max_fd = *fd;
324+
if (fds[1] > max_fd)
325+
max_fd = fds[1];
326+
327+
sread_sz = (max_fd + NBBY) / NBBY;
328+
swrite_sz = sread_sz;
329+
330+
s = malloc(sizeof(*s) + sread_sz + swrite_sz);
331+
if (s == NULL) {
332+
err = uv__set_artificial_error(stream->loop, UV_ENOMEM);
333+
goto failed_malloc;
334+
}
312335

313336
s->events = 0;
314337
s->fd = *fd;
338+
s->sread = (fd_set*) ((char*) s + sizeof(*s));
339+
s->sread_sz = sread_sz;
340+
s->swrite = (fd_set*) ((char*) s->sread + sread_sz);
341+
s->swrite_sz = swrite_sz;
315342

316-
if (uv_async_init(stream->loop, &s->async, uv__stream_osx_select_cb)) {
317-
SAVE_ERRNO(free(s));
318-
return uv__set_sys_error(stream->loop, errno);
319-
}
343+
err = uv_async_init(stream->loop, &s->async, uv__stream_osx_select_cb);
344+
if (err)
345+
goto failed_async_init;
320346

321347
s->async.flags |= UV__HANDLE_INTERNAL;
322348
uv__handle_unref(&s->async);
323349

324-
if (uv_sem_init(&s->close_sem, 0))
325-
goto fatal1;
326-
327-
if (uv_sem_init(&s->async_sem, 0))
328-
goto fatal2;
350+
err = uv_sem_init(&s->close_sem, 0);
351+
if (err != 0) {
352+
err = uv__set_sys_error(stream->loop, UV_UNKNOWN);
353+
goto failed_close_sem_init;
354+
}
329355

330-
/* Create fds for io watcher and to interrupt the select() loop. */
331-
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds))
332-
goto fatal3;
356+
err = uv_sem_init(&s->async_sem, 0);
357+
if (err != 0) {
358+
err = uv__set_sys_error(stream->loop, UV_UNKNOWN);
359+
goto failed_async_sem_init;
360+
}
333361

334362
s->fake_fd = fds[0];
335363
s->int_fd = fds[1];
@@ -339,26 +367,37 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) {
339367
stream->select = s;
340368
*fd = s->fake_fd;
341369

342-
if (uv_thread_create(&s->thread, uv__stream_osx_select, stream))
343-
goto fatal4;
370+
err = uv_thread_create(&s->thread, uv__stream_osx_select, stream);
371+
if (err != 0) {
372+
err = uv__set_sys_error(stream->loop, UV_UNKNOWN);
373+
goto failed_thread_create;
374+
}
344375

345376
return 0;
346377

347-
fatal4:
378+
failed_thread_create:
348379
s->stream = NULL;
349380
stream->select = NULL;
350381
*fd = old_fd;
351-
close(s->fake_fd);
352-
close(s->int_fd);
353-
s->fake_fd = -1;
354-
s->int_fd = -1;
355-
fatal3:
356382
uv_sem_destroy(&s->async_sem);
357-
fatal2:
383+
384+
failed_async_sem_init:
358385
uv_sem_destroy(&s->close_sem);
359-
fatal1:
386+
387+
failed_close_sem_init:
388+
close(fds[0]);
389+
close(fds[1]);
360390
uv_close((uv_handle_t*) &s->async, uv__stream_osx_cb_close);
361-
return uv__set_sys_error(stream->loop, errno);
391+
return err;
392+
393+
failed_async_init:
394+
free(s);
395+
396+
failed_malloc:
397+
close(fds[0]);
398+
close(fds[1]);
399+
400+
return err;
362401
}
363402
#endif /* defined(__APPLE__) */
364403

deps/uv/src/version.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
#define UV_VERSION_MAJOR 0
3636
#define UV_VERSION_MINOR 10
37-
#define UV_VERSION_PATCH 28
37+
#define UV_VERSION_PATCH 29
3838
#define UV_VERSION_IS_RELEASE 1
3939

4040

deps/uv/src/win/error.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
128128
case ERROR_DIRECTORY: return UV_ENOENT;
129129
case ERROR_FILE_NOT_FOUND: return UV_ENOENT;
130130
case ERROR_INVALID_NAME: return UV_ENOENT;
131+
case ERROR_INVALID_DRIVE: return UV_ENOENT;
131132
case ERROR_INVALID_REPARSE_DATA: return UV_ENOENT;
132133
case ERROR_MOD_NOT_FOUND: return UV_ENOENT;
133134
case ERROR_PATH_NOT_FOUND: return UV_ENOENT;

deps/uv/test/test-list.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ TEST_DECLARE (closed_fd_events)
232232
#endif
233233
#ifdef __APPLE__
234234
TEST_DECLARE (osx_select)
235+
TEST_DECLARE (osx_select_many_fds)
235236
#endif
236237
HELPER_DECLARE (tcp4_echo_server)
237238
HELPER_DECLARE (tcp6_echo_server)
@@ -468,6 +469,7 @@ TASK_LIST_START
468469

469470
#ifdef __APPLE__
470471
TEST_ENTRY (osx_select)
472+
TEST_ENTRY (osx_select_many_fds)
471473
#endif
472474

473475
TEST_ENTRY (fs_file_noent)

deps/uv/test/test-osx-select.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,51 @@ TEST_IMPL(osx_select) {
7979
return 0;
8080
}
8181

82+
83+
TEST_IMPL(osx_select_many_fds) {
84+
int r;
85+
int fd;
86+
size_t i;
87+
size_t len;
88+
const char* str;
89+
struct sockaddr_in addr;
90+
uv_tty_t tty;
91+
uv_tcp_t tcps[1500];
92+
93+
addr = uv_ip4_addr("127.0.0.1", 0);
94+
95+
for (i = 0; i < ARRAY_SIZE(tcps); i++) {
96+
r = uv_tcp_init(uv_default_loop(), &tcps[i]);
97+
ASSERT(r == 0);
98+
r = uv_tcp_bind(&tcps[i], addr);
99+
ASSERT(r == 0);
100+
uv_unref((uv_handle_t*) &tcps[i]);
101+
}
102+
103+
fd = open("/dev/tty", O_RDONLY);
104+
ASSERT(fd >= 0);
105+
106+
r = uv_tty_init(uv_default_loop(), &tty, fd, 1);
107+
ASSERT(r == 0);
108+
109+
r = uv_read_start((uv_stream_t*) &tty, alloc_cb, read_cb);
110+
ASSERT(r == 0);
111+
112+
/* Emulate user-input */
113+
str = "got some input\n"
114+
"with a couple of lines\n"
115+
"feel pretty happy\n";
116+
for (i = 0, len = strlen(str); i < len; i++) {
117+
r = ioctl(fd, TIOCSTI, str + i);
118+
ASSERT(r == 0);
119+
}
120+
121+
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
122+
123+
ASSERT(read_count == 3);
124+
125+
MAKE_VALGRIND_HAPPY();
126+
return 0;
127+
}
128+
82129
#endif /* __APPLE__ */

deps/uv/uv.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
},
195195
'defines': [
196196
'_DARWIN_USE_64_BIT_INODE=1',
197+
'_DARWIN_UNLIMITED_SELECT=1',
197198
]
198199
}],
199200
[ 'OS!="mac"', {

0 commit comments

Comments
 (0)