summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-05-24 14:26:32 -0700
committerisaacs <i@izs.me>2012-05-24 14:26:32 -0700
commit24de89bd0e47cb657afa386fa7b2d2ae94309254 (patch)
tree8c02717c994d5e99a7d089550d7a95562669c56a /deps
parentb4ed3c19697e875c289363381498a896347cbca6 (diff)
downloadnode-new-24de89bd0e47cb657afa386fa7b2d2ae94309254.tar.gz
Upgrade uv to 604802a
Diffstat (limited to 'deps')
-rw-r--r--deps/uv/config-unix.mk1
-rw-r--r--deps/uv/include/uv-private/uv-unix.h19
-rw-r--r--deps/uv/include/uv.h40
-rw-r--r--deps/uv/src/unix/core.c20
-rw-r--r--deps/uv/src/unix/internal.h15
-rw-r--r--deps/uv/src/unix/loop.c37
-rw-r--r--deps/uv/src/unix/pipe.c23
-rw-r--r--deps/uv/src/unix/poll.c1
-rw-r--r--deps/uv/src/unix/stream.c20
-rw-r--r--deps/uv/src/unix/tty.c2
-rw-r--r--deps/uv/src/unix/udp.c55
-rw-r--r--deps/uv/src/win/core.c2
-rw-r--r--deps/uv/test/benchmark-list.h2
-rw-r--r--deps/uv/test/benchmark-sizes.c1
-rw-r--r--deps/uv/test/test-fs.c12
-rw-r--r--deps/uv/test/test-ipc-send-recv.c5
-rw-r--r--deps/uv/test/test-list.h2
-rw-r--r--deps/uv/test/test-pipe-bind-error.c4
-rw-r--r--deps/uv/test/test-run-once.c26
-rw-r--r--deps/uv/uv.gyp3
20 files changed, 130 insertions, 160 deletions
diff --git a/deps/uv/config-unix.mk b/deps/uv/config-unix.mk
index ce98c1f053..c1ba2d0ad1 100644
--- a/deps/uv/config-unix.mk
+++ b/deps/uv/config-unix.mk
@@ -33,6 +33,7 @@ OBJS += src/unix/dl.o
OBJS += src/unix/error.o
OBJS += src/unix/fs.o
OBJS += src/unix/loop.o
+OBJS += src/unix/loop-watcher.o
OBJS += src/unix/pipe.o
OBJS += src/unix/poll.o
OBJS += src/unix/process.o
diff --git a/deps/uv/include/uv-private/uv-unix.h b/deps/uv/include/uv-private/uv-unix.h
index 71253bc9ad..27ed333cfd 100644
--- a/deps/uv/include/uv-private/uv-unix.h
+++ b/deps/uv/include/uv-private/uv-unix.h
@@ -131,10 +131,9 @@ struct uv__io_s {
#define UV_UDP_SEND_PRIVATE_FIELDS \
ngx_queue_t queue; \
- struct sockaddr_storage addr; \
- socklen_t addrlen; \
- uv_buf_t* bufs; \
+ struct sockaddr_in6 addr; \
int bufcnt; \
+ uv_buf_t* bufs; \
ssize_t status; \
uv_udp_send_cb send_cb; \
uv_buf_t bufsml[UV_REQ_BUFSML_SIZE]; \
@@ -144,7 +143,6 @@ struct uv__io_s {
/* TODO: union or classes please! */
#define UV_HANDLE_PRIVATE_FIELDS \
- int fd; \
int flags; \
uv_handle_t* next_pending; \
@@ -156,10 +154,10 @@ struct uv__io_s {
uv__io_t write_watcher; \
ngx_queue_t write_queue; \
ngx_queue_t write_completed_queue; \
- int delayed_error; \
uv_connection_cb connection_cb; \
+ int delayed_error; \
int accepted_fd; \
- int blocking;
+ int fd; \
/* UV_TCP */
@@ -168,6 +166,7 @@ struct uv__io_s {
/* UV_UDP */
#define UV_UDP_PRIVATE_FIELDS \
+ int fd; \
uv_alloc_cb alloc_cb; \
uv_udp_recv_cb recv_cb; \
uv__io_t read_watcher; \
@@ -183,6 +182,7 @@ struct uv__io_s {
/* UV_POLL */
#define UV_POLL_PRIVATE_FIELDS \
+ int fd; \
uv__io_t io_watcher;
@@ -248,7 +248,8 @@ struct uv__io_s {
struct uv_fs_event_s* rbe_parent; \
int rbe_color; \
} node; \
- uv_fs_event_cb cb;
+ uv_fs_event_cb cb; \
+ int fd; \
#elif defined(__APPLE__) \
|| defined(__FreeBSD__) \
@@ -260,6 +261,7 @@ struct uv__io_s {
ev_io event_watcher; \
uv_fs_event_cb cb; \
int fflags; \
+ int fd;
#elif defined(__sun)
@@ -267,7 +269,8 @@ struct uv__io_s {
# define UV_FS_EVENT_PRIVATE_FIELDS \
ev_io event_watcher; \
uv_fs_event_cb cb; \
- file_obj_t fo;
+ file_obj_t fo; \
+ int fd;
#else /* !PORT_SOURCE_FILE */
# define UV_FS_EVENT_PRIVATE_FIELDS
#endif
diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h
index 218cebe071..f784546795 100644
--- a/deps/uv/include/uv.h
+++ b/deps/uv/include/uv.h
@@ -230,14 +230,17 @@ UV_EXTERN uv_loop_t* uv_default_loop(void);
/*
* This function starts the event loop. It blocks until the reference count
- * of the loop drops to zero.
+ * of the loop drops to zero. Always returns zero.
*/
-UV_EXTERN int uv_run (uv_loop_t*);
+UV_EXTERN int uv_run(uv_loop_t*);
/*
- * This function polls for new events without blocking.
+ * Poll for new events once. Note that this function blocks if there are no
+ * pending events. Returns zero when done (no active handles or requests left),
+ * or non-zero if more events are expected (meaning you should call
+ * uv_run_once() again sometime in the future).
*/
-UV_EXTERN int uv_run_once (uv_loop_t*);
+UV_EXTERN int uv_run_once(uv_loop_t*);
/*
* Manually modify the event loop's reference count. Useful if the user wants
@@ -338,13 +341,13 @@ UV_EXTERN const char* uv_err_name(uv_err_t err);
#endif
#define UV_REQ_FIELDS \
- /* read-only */ \
- uv_req_type type; \
/* public */ \
void* data; \
UV_REQ_EXTRA_FIELDS \
/* private */ \
- UV_REQ_PRIVATE_FIELDS
+ UV_REQ_PRIVATE_FIELDS \
+ /* read-only */ \
+ uv_req_type type; \
/* Abstract base class of all requests. */
struct uv_req_s {
@@ -381,16 +384,17 @@ struct uv_shutdown_s {
# define UV_HANDLE_EXTRA_FIELDS
#endif
-#define UV_HANDLE_FIELDS \
- /* read-only */ \
- uv_loop_t* loop; \
- uv_handle_type type; \
- /* public */ \
- uv_close_cb close_cb; \
- void* data; \
- UV_HANDLE_EXTRA_FIELDS \
- /* private */ \
- UV_HANDLE_PRIVATE_FIELDS
+#define UV_HANDLE_FIELDS \
+ /* read-only */ \
+ uv_loop_t* loop; \
+ /* public */ \
+ uv_close_cb close_cb; \
+ void* data; \
+ /* read-only */ \
+ uv_handle_type type; \
+ /* private */ \
+ UV_HANDLE_PRIVATE_FIELDS \
+ UV_HANDLE_EXTRA_FIELDS \
/* The abstract base class of all handles. */
struct uv_handle_s {
@@ -1362,8 +1366,8 @@ typedef enum {
/* uv_fs_t is a subclass of uv_req_t */
struct uv_fs_s {
UV_REQ_FIELDS
- uv_loop_t* loop;
uv_fs_type fs_type;
+ uv_loop_t* loop;
uv_fs_cb cb;
ssize_t result;
void* ptr;
diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c
index 49785da035..657397becf 100644
--- a/deps/uv/src/unix/core.c
+++ b/deps/uv/src/unix/core.c
@@ -235,8 +235,7 @@ int uv_run(uv_loop_t* loop) {
int uv_run_once(uv_loop_t* loop) {
- uv__run(loop);
- return 0;
+ return uv__run(loop);
}
@@ -269,8 +268,8 @@ void uv__finish_close(uv_handle_t* handle) {
case UV_NAMED_PIPE:
case UV_TCP:
case UV_TTY:
- assert(!ev_is_active(&((uv_stream_t*)handle)->read_watcher));
- assert(!ev_is_active(&((uv_stream_t*)handle)->write_watcher));
+ assert(!uv__io_active(&((uv_stream_t*)handle)->read_watcher));
+ assert(!uv__io_active(&((uv_stream_t*)handle)->write_watcher));
assert(((uv_stream_t*)handle)->fd == -1);
uv__stream_destroy((uv_stream_t*)handle);
break;
@@ -318,6 +317,7 @@ static int uv_getaddrinfo_done(eio_req* req_) {
uv_getaddrinfo_t* req = req_->data;
struct addrinfo *res = req->res;
#if __sun
+ uv_getaddrinfo_t* handle = req->data;
size_t hostlen = strlen(handle->hostname);
#endif
@@ -446,14 +446,18 @@ out:
}
-int uv__accept(int sockfd, struct sockaddr* saddr, socklen_t slen) {
+int uv__accept(int sockfd) {
int peerfd;
assert(sockfd >= 0);
while (1) {
#if __linux__
- peerfd = uv__accept4(sockfd, saddr, &slen, UV__SOCK_NONBLOCK|UV__SOCK_CLOEXEC);
+ peerfd = uv__accept4(sockfd,
+ NULL,
+ NULL,
+ UV__SOCK_NONBLOCK|UV__SOCK_CLOEXEC);
+
if (peerfd != -1)
break;
@@ -464,7 +468,9 @@ int uv__accept(int sockfd, struct sockaddr* saddr, socklen_t slen) {
break;
#endif
- if ((peerfd = accept(sockfd, saddr, &slen)) == -1) {
+ peerfd = accept(sockfd, NULL, NULL);
+
+ if (peerfd == -1) {
if (errno == EINTR)
continue;
else
diff --git a/deps/uv/src/unix/internal.h b/deps/uv/src/unix/internal.h
index 328d76d77b..551d69040e 100644
--- a/deps/uv/src/unix/internal.h
+++ b/deps/uv/src/unix/internal.h
@@ -84,17 +84,18 @@
/* flags */
enum {
- UV_CLOSING = 0x01, /* uv_close() called but not finished. */
- UV_CLOSED = 0x02, /* close(2) finished. */
+ UV_CLOSING = 0x01, /* uv_close() called but not finished. */
+ UV_CLOSED = 0x02, /* close(2) finished. */
UV_STREAM_READING = 0x04, /* uv_read_start() called. */
UV_STREAM_SHUTTING = 0x08, /* uv_shutdown() called but not complete. */
UV_STREAM_SHUT = 0x10, /* Write side closed. */
UV_STREAM_READABLE = 0x20, /* The stream is readable */
UV_STREAM_WRITABLE = 0x40, /* The stream is writable */
- UV_TCP_NODELAY = 0x080, /* Disable Nagle. */
- UV_TCP_KEEPALIVE = 0x100, /* Turn on keep-alive. */
- UV_TIMER_REPEAT = 0x100,
- UV__PENDING = 0x800
+ UV_STREAM_BLOCKING = 0x80, /* Synchronous writes. */
+ UV_TCP_NODELAY = 0x100, /* Disable Nagle. */
+ UV_TCP_KEEPALIVE = 0x200, /* Turn on keep-alive. */
+ UV_TIMER_REPEAT = 0x100,
+ UV__PENDING = 0x800
};
inline static int uv__has_pending_handles(const uv_loop_t* loop) {
@@ -155,7 +156,7 @@ void uv__stream_init(uv_loop_t* loop, uv_stream_t* stream,
int uv__stream_open(uv_stream_t*, int fd, int flags);
void uv__stream_destroy(uv_stream_t* stream);
void uv__server_io(uv_loop_t* loop, uv__io_t* watcher, int events);
-int uv__accept(int sockfd, struct sockaddr* saddr, socklen_t len);
+int uv__accept(int sockfd);
int uv__connect(uv_connect_t* req, uv_stream_t* stream, struct sockaddr* addr,
socklen_t addrlen, uv_connect_cb cb);
diff --git a/deps/uv/src/unix/loop.c b/deps/uv/src/unix/loop.c
index 08b34994fc..14743daaf8 100644
--- a/deps/uv/src/unix/loop.c
+++ b/deps/uv/src/unix/loop.c
@@ -77,40 +77,3 @@ void uv__loop_delete(uv_loop_t* loop) {
close(loop->fs_fd);
#endif
}
-
-
-#define X(name, type) \
- int uv_##name##_init(uv_loop_t* loop, uv_##name##_t* handle) { \
- uv__handle_init(loop, (uv_handle_t*)handle, type); \
- loop->counters.name##_init++; \
- handle->name##_cb = NULL; \
- return 0; \
- } \
- int uv_##name##_start(uv_##name##_t* handle, uv_##name##_cb cb) { \
- if (uv__is_active(handle)) return 0; \
- ngx_queue_insert_head(&handle->loop->name##_handles, &handle->queue); \
- handle->name##_cb = cb; \
- uv__handle_start(handle); \
- return 0; \
- } \
- int uv_##name##_stop(uv_##name##_t* handle) { \
- if (!uv__is_active(handle)) return 0; \
- ngx_queue_remove(&handle->queue); \
- uv__handle_stop(handle); \
- return 0; \
- } \
- void uv__run_##name(uv_loop_t* loop) { \
- uv_##name##_t* h; \
- ngx_queue_t* q; \
- ngx_queue_foreach(q, &loop->name##_handles) { \
- h = ngx_queue_data(q, uv_##name##_t, queue); \
- if (h->name##_cb) h->name##_cb(h, 0); \
- } \
- } \
- void uv__##name##_close(uv_##name##_t* handle) { \
- uv_##name##_stop(handle); \
- }
-X(idle, UV_IDLE)
-X(check, UV_CHECK)
-X(prepare, UV_PREPARE)
-#undef X
diff --git a/deps/uv/src/unix/pipe.c b/deps/uv/src/unix/pipe.c
index fb40e9622a..666ebec833 100644
--- a/deps/uv/src/unix/pipe.c
+++ b/deps/uv/src/unix/pipe.c
@@ -81,22 +81,10 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
uv_strlcpy(saddr.sun_path, pipe_fname, sizeof(saddr.sun_path));
saddr.sun_family = AF_UNIX;
- if (bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr) == -1) {
- /* On EADDRINUSE:
- *
- * We hold the file lock so there is no other process listening
- * on the socket. Ergo, it's stale - remove it.
- *
- * This assumes that the other process uses locking too
- * but that's a good enough assumption for now.
- */
- if (errno != EADDRINUSE
- || unlink(pipe_fname) == -1
- || bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr) == -1) {
- /* Convert ENOENT to EACCES for compatibility with Windows. */
- uv__set_sys_error(handle->loop, (errno == ENOENT) ? EACCES : errno);
- goto out;
- }
+ if (bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr)) {
+ /* Convert ENOENT to EACCES for compatibility with Windows. */
+ uv__set_sys_error(handle->loop, (errno == ENOENT) ? EACCES : errno);
+ goto out;
}
bound = 1;
@@ -241,7 +229,6 @@ out:
/* TODO merge with uv__server_io()? */
static void uv__pipe_accept(uv_loop_t* loop, uv__io_t* w, int events) {
- struct sockaddr_un saddr;
uv_pipe_t* pipe;
int saved_errno;
int sockfd;
@@ -251,7 +238,7 @@ static void uv__pipe_accept(uv_loop_t* loop, uv__io_t* w, int events) {
assert(pipe->type == UV_NAMED_PIPE);
- sockfd = uv__accept(pipe->fd, (struct sockaddr *)&saddr, sizeof saddr);
+ sockfd = uv__accept(pipe->fd);
if (sockfd == -1) {
if (errno != EAGAIN && errno != EWOULDBLOCK) {
uv__set_sys_error(pipe->loop, errno);
diff --git a/deps/uv/src/unix/poll.c b/deps/uv/src/unix/poll.c
index f0a4344e18..13796ab575 100644
--- a/deps/uv/src/unix/poll.c
+++ b/deps/uv/src/unix/poll.c
@@ -100,6 +100,7 @@ int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) {
if (pevents & UV_WRITABLE)
events |= UV__IO_WRITE;
+ uv__io_stop(handle->loop, &handle->io_watcher);
uv__io_set(&handle->io_watcher, uv__poll_io, handle->fd, events);
uv__io_start(handle->loop, &handle->io_watcher);
diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c
index f441c9b945..7ea4487451 100644
--- a/deps/uv/src/unix/stream.c
+++ b/deps/uv/src/unix/stream.c
@@ -67,7 +67,6 @@ void uv__stream_init(uv_loop_t* loop,
stream->accepted_fd = -1;
stream->fd = -1;
stream->delayed_error = 0;
- stream->blocking = 0;
ngx_queue_init(&stream->write_queue);
ngx_queue_init(&stream->write_completed_queue);
stream->write_queue_size = 0;
@@ -166,7 +165,6 @@ void uv__stream_destroy(uv_stream_t* stream) {
void uv__server_io(uv_loop_t* loop, uv__io_t* w, int events) {
int fd;
- struct sockaddr_storage addr;
uv_stream_t* stream = container_of(w, uv_stream_t, read_watcher);
assert(events == UV__IO_READ);
@@ -182,7 +180,7 @@ void uv__server_io(uv_loop_t* loop, uv__io_t* w, int events) {
*/
while (stream->fd != -1) {
assert(stream->accepted_fd < 0);
- fd = uv__accept(stream->fd, (struct sockaddr*)&addr, sizeof addr);
+ fd = uv__accept(stream->fd);
if (fd < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
@@ -444,7 +442,7 @@ start:
stream->write_queue_size -= uv__write_req_size(req);
uv__write_req_finish(req);
return;
- } else if (stream->blocking) {
+ } else if (stream->flags & UV_STREAM_BLOCKING) {
/* If this is a blocking stream, try again. */
goto start;
}
@@ -465,7 +463,7 @@ start:
n = 0;
/* There is more to write. */
- if (stream->blocking) {
+ if (stream->flags & UV_STREAM_BLOCKING) {
/*
* If we're blocking then we should not be enabling the write
* watcher - instead we need to try again.
@@ -501,7 +499,7 @@ start:
assert(n == 0 || n == -1);
/* Only non-blocking streams should use the write_watcher. */
- assert(!stream->blocking);
+ assert(!(stream->flags & UV_STREAM_BLOCKING));
/* We're not done. */
uv__io_start(stream->loop, &stream->write_watcher);
@@ -626,7 +624,7 @@ static void uv__read(uv_stream_t* stream) {
stream->read2_cb((uv_pipe_t*)stream, -1, buf, UV_UNKNOWN_HANDLE);
}
- assert(!ev_is_active(&stream->read_watcher));
+ assert(!uv__io_active(&stream->read_watcher));
return;
}
@@ -634,7 +632,7 @@ static void uv__read(uv_stream_t* stream) {
/* EOF */
uv__set_artificial_error(stream->loop, UV_EOF);
uv__io_stop(stream->loop, &stream->read_watcher);
- if (!ev_is_active(&stream->write_watcher))
+ if (!uv__io_active(&stream->write_watcher))
uv__handle_stop(stream);
if (stream->read_cb) {
@@ -931,7 +929,7 @@ int uv_write2(uv_write_t* req, uv_stream_t* stream, uv_buf_t bufs[], int bufcnt,
* if this assert fires then somehow the blocking stream isn't being
* sufficently flushed in uv__write.
*/
- assert(!stream->blocking);
+ assert(!(stream->flags & UV_STREAM_BLOCKING));
uv__io_start(stream->loop, &stream->write_watcher);
}
@@ -1027,6 +1025,6 @@ void uv__stream_close(uv_stream_t* handle) {
handle->accepted_fd = -1;
}
- assert(!ev_is_active(&handle->read_watcher));
- assert(!ev_is_active(&handle->write_watcher));
+ assert(!uv__io_active(&handle->read_watcher));
+ assert(!uv__io_active(&handle->write_watcher));
}
diff --git a/deps/uv/src/unix/tty.c b/deps/uv/src/unix/tty.c
index 572d19c60a..7193db8bcb 100644
--- a/deps/uv/src/unix/tty.c
+++ b/deps/uv/src/unix/tty.c
@@ -42,7 +42,7 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int readable) {
} else {
/* Note: writable tty we set to blocking mode. */
uv__stream_open((uv_stream_t*)tty, fd, UV_STREAM_WRITABLE);
- tty->blocking = 1;
+ tty->flags |= UV_STREAM_BLOCKING;
}
loop->counters.tty_init++;
diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c
index a9c03066ad..523d2823d2 100644
--- a/deps/uv/src/unix/udp.c
+++ b/deps/uv/src/unix/udp.c
@@ -61,35 +61,9 @@ static void uv__udp_stop_watcher(uv_udp_t* handle, uv__io_t* w) {
}
-static void uv__udp_start_read_watcher(uv_udp_t* handle) {
- uv__udp_start_watcher(handle,
- &handle->read_watcher,
- uv__udp_recvmsg,
- UV__IO_READ);
-}
-
-
-static void uv__udp_start_write_watcher(uv_udp_t* handle) {
- uv__udp_start_watcher(handle,
- &handle->write_watcher,
- uv__udp_sendmsg,
- UV__IO_WRITE);
-}
-
-
-static void uv__udp_stop_read_watcher(uv_udp_t* handle) {
- uv__udp_stop_watcher(handle, &handle->read_watcher);
-}
-
-
-static void uv__udp_stop_write_watcher(uv_udp_t* handle) {
- uv__udp_stop_watcher(handle, &handle->write_watcher);
-}
-
-
void uv__udp_close(uv_udp_t* handle) {
- uv__udp_stop_write_watcher(handle);
- uv__udp_stop_read_watcher(handle);
+ uv__udp_stop_watcher(handle, &handle->write_watcher);
+ uv__udp_stop_watcher(handle, &handle->read_watcher);
close(handle->fd);
handle->fd = -1;
}
@@ -142,7 +116,8 @@ static void uv__udp_run_pending(uv_udp_t* handle) {
memset(&h, 0, sizeof h);
h.msg_name = &req->addr;
- h.msg_namelen = req->addrlen;
+ h.msg_namelen = (req->addr.sin6_family == AF_INET6 ?
+ sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in));
h.msg_iov = (struct iovec*)req->bufs;
h.msg_iovlen = req->bufcnt;
@@ -224,7 +199,7 @@ static void uv__udp_recvmsg(uv_loop_t* loop, uv__io_t* w, int revents) {
handle = container_of(w, uv_udp_t, read_watcher);
assert(handle->type == UV_UDP);
- assert(revents & EV_READ);
+ assert(revents & UV__IO_READ);
assert(handle->recv_cb != NULL);
assert(handle->alloc_cb != NULL);
@@ -281,7 +256,7 @@ static void uv__udp_sendmsg(uv_loop_t* loop, uv__io_t* w, int revents) {
handle = container_of(w, uv_udp_t, write_watcher);
assert(handle->type == UV_UDP);
- assert(revents & EV_WRITE);
+ assert(revents & UV__IO_WRITE);
assert(!ngx_queue_empty(&handle->write_queue)
|| !ngx_queue_empty(&handle->write_completed_queue));
@@ -298,7 +273,7 @@ static void uv__udp_sendmsg(uv_loop_t* loop, uv__io_t* w, int revents) {
}
else if (ngx_queue_empty(&handle->write_queue)) {
/* Pending queue and completion queue empty, stop watcher. */
- uv__udp_stop_write_watcher(handle);
+ uv__udp_stop_watcher(handle, &handle->write_watcher);
}
}
@@ -441,8 +416,8 @@ static int uv__udp_send(uv_udp_send_t* req,
uv__req_init(handle->loop, req, UV_UDP_SEND);
+ assert(addrlen <= sizeof(req->addr));
memcpy(&req->addr, addr, addrlen);
- req->addrlen = addrlen;
req->send_cb = send_cb;
req->handle = handle;
req->bufcnt = bufcnt;
@@ -457,7 +432,11 @@ static int uv__udp_send(uv_udp_send_t* req,
memcpy(req->bufs, bufs, bufcnt * sizeof(bufs[0]));
ngx_queue_insert_tail(&handle->write_queue, &req->queue);
- uv__udp_start_write_watcher(handle);
+
+ uv__udp_start_watcher(handle,
+ &handle->write_watcher,
+ uv__udp_sendmsg,
+ UV__IO_WRITE);
return 0;
}
@@ -657,14 +636,18 @@ int uv_udp_recv_start(uv_udp_t* handle,
handle->alloc_cb = alloc_cb;
handle->recv_cb = recv_cb;
- uv__udp_start_read_watcher(handle);
+
+ uv__udp_start_watcher(handle,
+ &handle->read_watcher,
+ uv__udp_recvmsg,
+ UV__IO_READ);
return 0;
}
int uv_udp_recv_stop(uv_udp_t* handle) {
- uv__udp_stop_read_watcher(handle);
+ uv__udp_stop_watcher(handle, &handle->read_watcher);
handle->alloc_cb = NULL;
handle->recv_cb = NULL;
return 0;
diff --git a/deps/uv/src/win/core.c b/deps/uv/src/win/core.c
index c24cfc3bbb..f32b9162a2 100644
--- a/deps/uv/src/win/core.c
+++ b/deps/uv/src/win/core.c
@@ -268,7 +268,7 @@ int uv_run_once(uv_loop_t* loop) {
} else {
UV_LOOP_ONCE(loop, uv_poll);
}
- return 0;
+ return UV_LOOP_ALIVE(loop);
}
diff --git a/deps/uv/test/benchmark-list.h b/deps/uv/test/benchmark-list.h
index deb5ed1f74..26267f4acc 100644
--- a/deps/uv/test/benchmark-list.h
+++ b/deps/uv/test/benchmark-list.h
@@ -20,6 +20,7 @@
*/
BENCHMARK_DECLARE (sizes)
+BENCHMARK_DECLARE (loop_count)
BENCHMARK_DECLARE (ping_pongs)
BENCHMARK_DECLARE (tcp_write_batch)
BENCHMARK_DECLARE (tcp4_pound_100)
@@ -53,6 +54,7 @@ HELPER_DECLARE (dns_server)
TASK_LIST_START
BENCHMARK_ENTRY (sizes)
+ BENCHMARK_ENTRY (loop_count)
BENCHMARK_ENTRY (ping_pongs)
BENCHMARK_HELPER (ping_pongs, tcp4_echo_server)
diff --git a/deps/uv/test/benchmark-sizes.c b/deps/uv/test/benchmark-sizes.c
index 09e06e8f3d..6d16e3ca50 100644
--- a/deps/uv/test/benchmark-sizes.c
+++ b/deps/uv/test/benchmark-sizes.c
@@ -27,6 +27,7 @@ BENCHMARK_IMPL(sizes) {
LOGF("uv_shutdown_t: %u bytes\n", (unsigned int) sizeof(uv_shutdown_t));
LOGF("uv_write_t: %u bytes\n", (unsigned int) sizeof(uv_write_t));
LOGF("uv_connect_t: %u bytes\n", (unsigned int) sizeof(uv_connect_t));
+ LOGF("uv_udp_send_t: %u bytes\n", (unsigned int) sizeof(uv_udp_send_t));
LOGF("uv_tcp_t: %u bytes\n", (unsigned int) sizeof(uv_tcp_t));
LOGF("uv_pipe_t: %u bytes\n", (unsigned int) sizeof(uv_pipe_t));
LOGF("uv_tty_t: %u bytes\n", (unsigned int) sizeof(uv_tty_t));
diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c
index be962e824c..36b68f3033 100644
--- a/deps/uv/test/test-fs.c
+++ b/deps/uv/test/test-fs.c
@@ -1305,7 +1305,6 @@ TEST_IMPL(fs_symlink) {
TEST_IMPL(fs_symlink_dir) {
uv_fs_t req;
int r;
- char src_path_buf[PATHMAX];
char* test_dir;
/* set-up */
@@ -1320,10 +1319,13 @@ TEST_IMPL(fs_symlink_dir) {
uv_fs_req_cleanup(&req);
#ifdef _WIN32
- strcpy(src_path_buf, "\\\\?\\");
- uv_cwd(src_path_buf + 4, sizeof(src_path_buf)/sizeof(src_path_buf[0]));
- strcat(src_path_buf, "\\test_dir\\");
- test_dir = src_path_buf;
+ {
+ static char src_path_buf[PATHMAX];
+ strcpy(src_path_buf, "\\\\?\\");
+ uv_cwd(src_path_buf + 4, sizeof(src_path_buf));
+ strcat(src_path_buf, "\\test_dir\\");
+ test_dir = src_path_buf;
+ }
#else
test_dir = "test_dir";
#endif
diff --git a/deps/uv/test/test-ipc-send-recv.c b/deps/uv/test/test-ipc-send-recv.c
index 970bf1effe..faedc5469d 100644
--- a/deps/uv/test/test-ipc-send-recv.c
+++ b/deps/uv/test/test-ipc-send-recv.c
@@ -120,6 +120,11 @@ TEST_IMPL(ipc_send_recv_pipe) {
r = uv_pipe_init(uv_default_loop(), &ctx.send.pipe, 1);
ASSERT(r == 0);
+#ifndef _WIN32
+ /* Clean up stale socket from previous test run. */
+ remove(TEST_PIPENAME);
+#endif
+
r = uv_pipe_bind(&ctx.send.pipe, TEST_PIPENAME);
ASSERT(r == 0);
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index 134cb8cea2..6b2883cf49 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -21,6 +21,7 @@
TEST_DECLARE (platform_output)
TEST_DECLARE (callback_order)
+TEST_DECLARE (run_once)
TEST_DECLARE (tty)
TEST_DECLARE (stdio_over_pipes)
TEST_DECLARE (ipc_listen_before_write)
@@ -185,6 +186,7 @@ TASK_LIST_START
#if 0
TEST_ENTRY (callback_order)
#endif
+ TEST_ENTRY (run_once)
TEST_ENTRY (pipe_connect_bad_name)
TEST_ENTRY (pipe_connect_to_file)
diff --git a/deps/uv/test/test-pipe-bind-error.c b/deps/uv/test/test-pipe-bind-error.c
index b84d20f1ea..4e73b639b6 100644
--- a/deps/uv/test/test-pipe-bind-error.c
+++ b/deps/uv/test/test-pipe-bind-error.c
@@ -27,8 +27,10 @@
#ifdef _WIN32
# define BAD_PIPENAME "bad-pipe"
+# define UNLINK_PIPE(name)
#else
# define BAD_PIPENAME "/path/to/unix/socket/that/really/should/not/be/there"
+# define UNLINK_PIPE(name) remove(name)
#endif
@@ -45,6 +47,8 @@ TEST_IMPL(pipe_bind_error_addrinuse) {
uv_pipe_t server1, server2;
int r;
+ UNLINK_PIPE(TEST_PIPENAME);
+
r = uv_pipe_init(uv_default_loop(), &server1, 0);
ASSERT(r == 0);
r = uv_pipe_bind(&server1, TEST_PIPENAME);
diff --git a/deps/uv/test/test-run-once.c b/deps/uv/test/test-run-once.c
index c03ab88e8f..f74e9f37a5 100644
--- a/deps/uv/test/test-run-once.c
+++ b/deps/uv/test/test-run-once.c
@@ -22,23 +22,27 @@
#include "uv.h"
#include "task.h"
-static idle_counter = 0;
+#define NUM_TICKS 64
+
+static uv_idle_t idle_handle;
+static int idle_counter;
+
static void idle_cb(uv_idle_t* handle, int status) {
- ASSERT(handle != NULL);
+ ASSERT(handle == &idle_handle);
ASSERT(status == 0);
- idle_counter ++;
+
+ if (++idle_counter == NUM_TICKS)
+ uv_idle_stop(handle);
}
TEST_IMPL(run_once) {
- int n;
- uv_idle_t h;
- uv_idle_init(uv_default_loop(), &h);
- uv_idle_start(&h, idle_cb);
- for (n = 0; n < 500; n++) {
- uv_run_once(uv_default_loop());
- }
- ASSERT(n == 500);
+ uv_idle_init(uv_default_loop(), &idle_handle);
+ uv_idle_start(&idle_handle, idle_cb);
+
+ while (uv_run_once(uv_default_loop()));
+ ASSERT(idle_counter == NUM_TICKS);
+
return 0;
}
diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp
index 28f9994826..605b5b1c56 100644
--- a/deps/uv/uv.gyp
+++ b/deps/uv/uv.gyp
@@ -195,6 +195,7 @@
'src/unix/fs.c',
'src/unix/internal.h',
'src/unix/loop.c',
+ 'src/unix/loop-watcher.c',
'src/unix/pipe.c',
'src/unix/poll.c',
'src/unix/process.c',
@@ -328,6 +329,7 @@
'test/test-poll.c',
'test/test-process-title.c',
'test/test-ref.c',
+ 'test/test-run-once.c',
'test/test-shutdown-close.c',
'test/test-shutdown-eof.c',
'test/test-spawn.c',
@@ -393,6 +395,7 @@
'test/benchmark-ares.c',
'test/benchmark-getaddrinfo.c',
'test/benchmark-list.h',
+ 'test/benchmark-loop-count.c',
'test/benchmark-ping-pongs.c',
'test/benchmark-pound.c',
'test/benchmark-pump.c',