Skip to content

Commit 2433eeb

Browse files
committed
uv: upgrade to 1cca230
1 parent ff51263 commit 2433eeb

22 files changed

+188
-161
lines changed

deps/uv/common.gypi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@
153153
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
154154
'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics
155155
'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES', # -Wnewline-eof
156-
'MACOSX_DEPLOYMENT_TARGET': '10.4', # -mmacosx-version-min=10.4
157156
'PREBINDING': 'NO', # No -Wl,-prebind
158157
'USE_HEADERMAP': 'NO',
159158
'OTHER_CFLAGS': [

deps/uv/gyp_uv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ if __name__ == '__main__':
4545

4646
# There's a bug with windows which doesn't allow this feature.
4747
if sys.platform != 'win32':
48-
4948
# Tell gyp to write the Makefiles into output_dir
5049
args.extend(['--generator-output', output_dir])
51-
5250
# Tell make to write its output into the same dir
5351
args.extend(['-Goutput_dir=' + output_dir])
52+
# Create Makefiles, not XCode projects
53+
args.extend('-f make'.split())
5454

5555
args.append('-Dtarget_arch=ia32')
5656
args.append('-Dcomponent=static_library')

deps/uv/include/uv.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,32 @@ UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle,
653653
const char* multicast_addr, const char* interface_addr,
654654
uv_membership membership);
655655

656+
/*
657+
* Set the multicast ttl
658+
*
659+
* Arguments:
660+
* handle UDP handle. Should have been initialized with
661+
* `uv_udp_init`.
662+
* ttl 1 through 255
663+
*
664+
* Returns:
665+
* 0 on success, -1 on error.
666+
*/
667+
int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl);
668+
669+
/*
670+
* Set broadcast on or off
671+
*
672+
* Arguments:
673+
* handle UDP handle. Should have been initialized with
674+
* `uv_udp_init`.
675+
* on 1 for on, 0 for off
676+
*
677+
* Returns:
678+
* 0 on success, -1 on error.
679+
*/
680+
int uv_udp_set_broadcast(uv_udp_t* handle, int on);
681+
656682
/*
657683
* Send data. If the socket has not previously been bound with `uv_udp_bind`
658684
* or `uv_udp_bind6`, it is bound to 0.0.0.0 (the "all interfaces" address)

deps/uv/src/unix/core.c

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ static void uv__finish_close(uv_handle_t* handle);
6464

6565

6666
void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
67-
uv_udp_t* udp;
6867
uv_async_t* async;
6968
uv_timer_t* timer;
7069
uv_stream_t* stream;
@@ -97,11 +96,7 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
9796
break;
9897

9998
case UV_UDP:
100-
udp = (uv_udp_t*)handle;
101-
uv__udp_watcher_stop(udp, &udp->read_watcher);
102-
uv__udp_watcher_stop(udp, &udp->write_watcher);
103-
uv__close(udp->fd);
104-
udp->fd = -1;
99+
uv__udp_start_close((uv_udp_t*)handle);
105100
break;
106101

107102
case UV_PREPARE:
@@ -234,7 +229,6 @@ void uv__handle_init(uv_loop_t* loop, uv_handle_t* handle,
234229
handle->flags = 0;
235230

236231
ev_init(&handle->next_watcher, uv__next);
237-
handle->next_watcher.data = handle;
238232

239233
/* Ref the loop until this handle is closed. See uv__finish_close. */
240234
ev_ref(loop->ev);
@@ -279,10 +273,7 @@ void uv__finish_close(uv_handle_t* handle) {
279273
break;
280274

281275
case UV_UDP:
282-
assert(!ev_is_active(&((uv_udp_t*)handle)->read_watcher));
283-
assert(!ev_is_active(&((uv_udp_t*)handle)->write_watcher));
284-
assert(((uv_udp_t*)handle)->fd == -1);
285-
uv__udp_destroy((uv_udp_t*)handle);
276+
uv__udp_finish_close((uv_udp_t*)handle);
286277
break;
287278

288279
case UV_PROCESS:
@@ -307,9 +298,9 @@ void uv__finish_close(uv_handle_t* handle) {
307298
}
308299

309300

310-
void uv__next(EV_P_ ev_idle* watcher, int revents) {
311-
uv_handle_t* handle = watcher->data;
312-
assert(watcher == &handle->next_watcher);
301+
void uv__next(EV_P_ ev_idle* w, int revents) {
302+
uv_handle_t* handle = container_of(w, uv_handle_t, next_watcher);
303+
313304
assert(revents == EV_IDLE);
314305

315306
/* For now this function is only to handle the closing event, but we might
@@ -347,7 +338,7 @@ void uv__req_init(uv_loop_t* loop, uv_req_t* req) {
347338

348339

349340
static void uv__prepare(EV_P_ ev_prepare* w, int revents) {
350-
uv_prepare_t* prepare = w->data;
341+
uv_prepare_t* prepare = container_of(w, uv_prepare_t, prepare_watcher);
351342

352343
if (prepare->prepare_cb) {
353344
prepare->prepare_cb(prepare, 0);
@@ -360,8 +351,6 @@ int uv_prepare_init(uv_loop_t* loop, uv_prepare_t* prepare) {
360351
loop->counters.prepare_init++;
361352

362353
ev_prepare_init(&prepare->prepare_watcher, uv__prepare);
363-
prepare->prepare_watcher.data = prepare;
364-
365354
prepare->prepare_cb = NULL;
366355

367356
return 0;
@@ -397,7 +386,7 @@ int uv_prepare_stop(uv_prepare_t* prepare) {
397386

398387

399388
static void uv__check(EV_P_ ev_check* w, int revents) {
400-
uv_check_t* check = w->data;
389+
uv_check_t* check = container_of(w, uv_check_t, check_watcher);
401390

402391
if (check->check_cb) {
403392
check->check_cb(check, 0);
@@ -410,8 +399,6 @@ int uv_check_init(uv_loop_t* loop, uv_check_t* check) {
410399
loop->counters.check_init++;
411400

412401
ev_check_init(&check->check_watcher, uv__check);
413-
check->check_watcher.data = check;
414-
415402
check->check_cb = NULL;
416403

417404
return 0;
@@ -447,7 +434,7 @@ int uv_check_stop(uv_check_t* check) {
447434

448435

449436
static void uv__idle(EV_P_ ev_idle* w, int revents) {
450-
uv_idle_t* idle = (uv_idle_t*)(w->data);
437+
uv_idle_t* idle = container_of(w, uv_idle_t, idle_watcher);
451438

452439
if (idle->idle_cb) {
453440
idle->idle_cb(idle, 0);
@@ -461,8 +448,6 @@ int uv_idle_init(uv_loop_t* loop, uv_idle_t* idle) {
461448
loop->counters.idle_init++;
462449

463450
ev_idle_init(&idle->idle_watcher, uv__idle);
464-
idle->idle_watcher.data = idle;
465-
466451
idle->idle_cb = NULL;
467452

468453
return 0;
@@ -517,7 +502,7 @@ int uv_is_active(uv_handle_t* handle) {
517502

518503

519504
static void uv__async(EV_P_ ev_async* w, int revents) {
520-
uv_async_t* async = w->data;
505+
uv_async_t* async = container_of(w, uv_async_t, async_watcher);
521506

522507
if (async->async_cb) {
523508
async->async_cb(async, 0);
@@ -530,8 +515,6 @@ int uv_async_init(uv_loop_t* loop, uv_async_t* async, uv_async_cb async_cb) {
530515
loop->counters.async_init++;
531516

532517
ev_async_init(&async->async_watcher, uv__async);
533-
async->async_watcher.data = async;
534-
535518
async->async_cb = async_cb;
536519

537520
/* Note: This does not have symmetry with the other libev wrappers. */
@@ -549,7 +532,7 @@ int uv_async_send(uv_async_t* async) {
549532

550533

551534
static void uv__timer_cb(EV_P_ ev_timer* w, int revents) {
552-
uv_timer_t* timer = w->data;
535+
uv_timer_t* timer = container_of(w, uv_timer_t, timer_watcher);
553536

554537
if (!ev_is_active(w)) {
555538
ev_ref(EV_A);
@@ -566,7 +549,6 @@ int uv_timer_init(uv_loop_t* loop, uv_timer_t* timer) {
566549
loop->counters.timer_init++;
567550

568551
ev_init(&timer->timer_watcher, uv__timer_cb);
569-
timer->timer_watcher.data = timer;
570552

571553
return 0;
572554
}
@@ -790,23 +772,6 @@ int uv__accept(int sockfd, struct sockaddr* saddr, socklen_t slen) {
790772
}
791773

792774

793-
int uv__close(int fd) {
794-
int status;
795-
796-
/*
797-
* Retry on EINTR. You may think this is academic but on linux
798-
* and probably other Unices too, close(2) is interruptible.
799-
* Failing to handle EINTR is a common source of fd leaks.
800-
*/
801-
do {
802-
status = close(fd);
803-
}
804-
while (status == -1 && errno == EINTR);
805-
806-
return status;
807-
}
808-
809-
810775
int uv__nonblock(int fd, int set) {
811776
#if FIONBIO
812777
return ioctl(fd, FIONBIO, &set);

deps/uv/src/unix/ev/ev_kqueue.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,6 @@ kqueue_destroy (EV_P)
200200
void inline_size
201201
kqueue_fork (EV_P)
202202
{
203-
close (backend_fd);
204-
205203
while ((backend_fd = kqueue ()) < 0)
206204
ev_syserr ("(libev) kqueue");
207205

deps/uv/src/unix/internal.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,19 @@ enum {
154154
UV_TCP_KEEPALIVE = 0x100 /* Turn on keep-alive. */
155155
};
156156

157-
int uv__close(int fd);
157+
/* core */
158158
void uv__handle_init(uv_loop_t* loop, uv_handle_t* handle, uv_handle_type type);
159-
160-
161159
int uv__nonblock(int fd, int set) __attribute__((unused));
162160
int uv__cloexec(int fd, int set) __attribute__((unused));
163161
int uv__socket(int domain, int type, int protocol);
164162

163+
/* We used to handle EINTR in uv__close() but linux 2.6 will have closed the
164+
* file descriptor anyway, even on EINTR. Retrying in that case isn't merely
165+
* useless, it's actively harmful - the file descriptor may have been acquired
166+
* by another thread.
167+
*/
168+
#define uv__close(fd) close(fd)
169+
165170
/* error */
166171
uv_err_code uv_translate_sys_error(int sys_errno);
167172
void uv_fatal_error(const int errorno, const char* syscall);
@@ -191,8 +196,8 @@ void uv__pipe_accept(EV_P_ ev_io* watcher, int revents);
191196
int uv_pipe_cleanup(uv_pipe_t* handle);
192197

193198
/* udp */
194-
void uv__udp_destroy(uv_udp_t* handle);
195-
void uv__udp_watcher_stop(uv_udp_t* handle, ev_io* w);
199+
void uv__udp_start_close(uv_udp_t* handle);
200+
void uv__udp_finish_close(uv_udp_t* handle);
196201

197202
/* fs */
198203
void uv__fs_event_destroy(uv_fs_event_t* handle);

deps/uv/src/unix/tty.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,15 @@ uv_handle_type uv_guess_handle(uv_file file) {
120120
struct stat s;
121121

122122
if (file < 0) {
123-
uv__set_sys_error(NULL, EINVAL); /* XXX Need loop? */
124-
return -1;
123+
return UV_UNKNOWN_HANDLE;
125124
}
126125

127126
if (isatty(file)) {
128127
return UV_TTY;
129128
}
130129

131130
if (fstat(file, &s)) {
132-
uv__set_sys_error(NULL, errno); /* XXX Need loop? */
133-
return -1;
131+
return UV_UNKNOWN_HANDLE;
134132
}
135133

136134
if (!S_ISSOCK(s.st_mode) && !S_ISFIFO(s.st_mode)) {

0 commit comments

Comments
 (0)