summaryrefslogtreecommitdiff
path: root/deps/uv
diff options
context:
space:
mode:
authorBert Belder <bertbelder@gmail.com>2012-08-28 02:43:55 +0200
committerBert Belder <bertbelder@gmail.com>2012-08-28 02:44:36 +0200
commit4822d780bb913c9ef7c2301a181a5834887cddb4 (patch)
tree646645a4d2901ff2209edd1a24683dff22496862 /deps/uv
parent985e3a25cb93f82dbef9b1b4279b8614f508898c (diff)
downloadnode-4822d780bb913c9ef7c2301a181a5834887cddb4.tar.gz
uv: upgrade to 621a4e3
Diffstat (limited to 'deps/uv')
-rw-r--r--deps/uv/include/uv-private/uv-win.h6
-rw-r--r--deps/uv/include/uv.h7
-rw-r--r--deps/uv/src/fs-poll.c1
-rw-r--r--deps/uv/src/unix/async.c2
-rw-r--r--deps/uv/src/unix/error.c1
-rw-r--r--deps/uv/src/unix/linux/linux-core.c5
-rw-r--r--deps/uv/src/unix/stream.c15
-rw-r--r--deps/uv/src/unix/thread.c13
-rw-r--r--deps/uv/src/unix/udp.c7
-rw-r--r--deps/uv/src/uv-common.h16
-rw-r--r--deps/uv/src/win/async.c3
-rw-r--r--deps/uv/src/win/fs-event.c3
-rw-r--r--deps/uv/src/win/handle-inl.h17
-rw-r--r--deps/uv/src/win/handle.c11
-rw-r--r--deps/uv/src/win/loop-watcher.c1
-rw-r--r--deps/uv/src/win/pipe.c3
-rw-r--r--deps/uv/src/win/poll.c5
-rw-r--r--deps/uv/src/win/process.c4
-rw-r--r--deps/uv/src/win/signal.c5
-rw-r--r--deps/uv/src/win/tcp.c3
-rw-r--r--deps/uv/src/win/timer.c1
-rw-r--r--deps/uv/src/win/tty.c18
-rw-r--r--deps/uv/src/win/udp.c3
-rw-r--r--deps/uv/test/benchmark-list.h66
-rw-r--r--deps/uv/test/benchmark-udp-packet-storm.c247
-rw-r--r--deps/uv/test/benchmark-udp-pummel.c229
-rw-r--r--deps/uv/test/test-active.c82
-rw-r--r--deps/uv/test/test-list.h3
-rw-r--r--deps/uv/uv.gyp5
29 files changed, 460 insertions, 322 deletions
diff --git a/deps/uv/include/uv-private/uv-win.h b/deps/uv/include/uv-private/uv-win.h
index ad27ee518..80f9faf28 100644
--- a/deps/uv/include/uv-private/uv-win.h
+++ b/deps/uv/include/uv-private/uv-win.h
@@ -67,6 +67,12 @@ typedef intptr_t ssize_t;
#define SIGKILL 9
#define SIGWINCH 28
+/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many */
+/* unix-like platforms. However MinGW doesn't define it, so we do. */
+#ifndef SIGABRT_COMPAT
+# define SIGABRT_COMPAT 6
+#endif
+
/*
* Guids and typedefs for winsock extension functions
* Mingw32 doesn't have these :-(
diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h
index 0e90a392e..4078bcd87 100644
--- a/deps/uv/include/uv.h
+++ b/deps/uv/include/uv.h
@@ -120,9 +120,10 @@ extern "C" {
XX( 53, ENOTEMPTY, "directory not empty") \
XX( 54, ENOSPC, "no space left on device") \
XX( 55, EIO, "i/o error") \
- XX( 56, EROFS, "read-only file system" ) \
- XX( 57, ENODEV, "no such device" ) \
- XX( 58, ECANCELED, "operation canceled" )
+ XX( 56, EROFS, "read-only file system") \
+ XX( 57, ENODEV, "no such device") \
+ XX( 58, ESPIPE, "invalid seek") \
+ XX( 59, ECANCELED, "operation canceled") \
#define UV_ERRNO_GEN(val, name, s) UV_##name = val,
diff --git a/deps/uv/src/fs-poll.c b/deps/uv/src/fs-poll.c
index c952dfc9c..f0fadd5d3 100644
--- a/deps/uv/src/fs-poll.c
+++ b/deps/uv/src/fs-poll.c
@@ -238,7 +238,6 @@ static int statbuf_eq(const uv_statbuf_t* a, const uv_statbuf_t* b) {
void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle) {
assert(handle->flags & UV_HANDLE_CLOSING);
assert(!(handle->flags & UV_HANDLE_CLOSED));
- uv__handle_stop(handle);
uv__handle_close(handle);
}
diff --git a/deps/uv/src/unix/async.c b/deps/uv/src/unix/async.c
index 6386c6d6f..78c1863ea 100644
--- a/deps/uv/src/unix/async.c
+++ b/deps/uv/src/unix/async.c
@@ -55,7 +55,7 @@ inline static int uv__async_make_pending(volatile sig_atomic_t* ptr) {
return __sync_val_compare_and_swap(ptr, 0, 1) != 0;
#else
*ptr = 1;
- return 1;
+ return 0;
#endif
}
diff --git a/deps/uv/src/unix/error.c b/deps/uv/src/unix/error.c
index 9fbb312ee..b2add994a 100644
--- a/deps/uv/src/unix/error.c
+++ b/deps/uv/src/unix/error.c
@@ -68,6 +68,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) {
case EAFNOSUPPORT: return UV_EAFNOSUPPORT;
case EBADF: return UV_EBADF;
case EPIPE: return UV_EPIPE;
+ case ESPIPE: return UV_ESPIPE;
case EAGAIN: return UV_EAGAIN;
#if EWOULDBLOCK != EAGAIN
case EWOULDBLOCK: return UV_EAGAIN;
diff --git a/deps/uv/src/unix/linux/linux-core.c b/deps/uv/src/unix/linux/linux-core.c
index f20edd082..167423f14 100644
--- a/deps/uv/src/unix/linux/linux-core.c
+++ b/deps/uv/src/unix/linux/linux-core.c
@@ -469,8 +469,9 @@ static unsigned long read_cpufreq(unsigned int cpunum) {
if (fp == NULL)
return 0;
- val = 0;
- fscanf(fp, "%lu", &val);
+ if (fscanf(fp, "%lu", &val) != 1)
+ val = 0;
+
fclose(fp);
return val;
diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c
index f9fc7195d..344118569 100644
--- a/deps/uv/src/unix/stream.c
+++ b/deps/uv/src/unix/stream.c
@@ -655,7 +655,13 @@ start:
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = msg.msg_controllen;
- *(int*) CMSG_DATA(cmsg) = fd_to_send;
+
+ /* silence aliasing warning */
+ {
+ void* pv = CMSG_DATA(cmsg);
+ int* pi = pv;
+ *pi = fd_to_send;
+ }
do {
n = sendmsg(stream->fd, &msg, 0);
@@ -909,7 +915,12 @@ static void uv__read(uv_stream_t* stream) {
fprintf(stderr, "(libuv) ignoring extra FD received\n");
}
- stream->accepted_fd = *(int *) CMSG_DATA(cmsg);
+ /* silence aliasing warning */
+ {
+ void* pv = CMSG_DATA(cmsg);
+ int* pi = pv;
+ stream->accepted_fd = *pi;
+ }
} else {
fprintf(stderr, "ignoring non-SCM_RIGHTS ancillary data: %d\n",
diff --git a/deps/uv/src/unix/thread.c b/deps/uv/src/unix/thread.c
index 67c787698..f85de1a4a 100644
--- a/deps/uv/src/unix/thread.c
+++ b/deps/uv/src/unix/thread.c
@@ -170,7 +170,10 @@ void uv_once(uv_once_t* guard, void (*callback)(void)) {
#if defined(__APPLE__) && defined(__MACH__)
int uv_sem_init(uv_sem_t* sem, unsigned int value) {
- return semaphore_create(mach_task_self(), sem, SYNC_POLICY_FIFO, value);
+ if (semaphore_create(mach_task_self(), sem, SYNC_POLICY_FIFO, value))
+ return -1;
+ else
+ return 0;
}
@@ -187,7 +190,13 @@ void uv_sem_post(uv_sem_t* sem) {
void uv_sem_wait(uv_sem_t* sem) {
- if (semaphore_wait(*sem))
+ int r;
+
+ do
+ r = semaphore_wait(*sem);
+ while (r == KERN_ABORTED);
+
+ if (r != KERN_SUCCESS)
abort();
}
diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c
index 1838bc796..c49668744 100644
--- a/deps/uv/src/unix/udp.c
+++ b/deps/uv/src/unix/udp.c
@@ -86,6 +86,10 @@ void uv__udp_finish_close(uv_udp_t* handle) {
req = ngx_queue_data(q, uv_udp_send_t, queue);
uv__req_unregister(handle->loop, req);
+ if (req->bufs != req->bufsml)
+ free(req->bufs);
+ req->bufs = NULL;
+
if (req->send_cb) {
/* FIXME proper error code like UV_EABORTED */
uv__set_artificial_error(handle->loop, UV_EINTR);
@@ -171,6 +175,7 @@ static void uv__udp_run_completed(uv_udp_t* handle) {
if (req->bufs != req->bufsml)
free(req->bufs);
+ req->bufs = NULL;
if (req->send_cb == NULL)
continue;
@@ -375,7 +380,7 @@ out:
static int uv__udp_maybe_deferred_bind(uv_udp_t* handle, int domain) {
- struct sockaddr_storage taddr;
+ unsigned char taddr[sizeof(struct sockaddr_in6)];
socklen_t addrlen;
assert(domain == AF_INET || domain == AF_INET6);
diff --git a/deps/uv/src/uv-common.h b/deps/uv/src/uv-common.h
index 4608ee549..e9caed9af 100644
--- a/deps/uv/src/uv-common.h
+++ b/deps/uv/src/uv-common.h
@@ -53,12 +53,14 @@
enum {
UV__HANDLE_INTERNAL = 0x8000,
UV__HANDLE_ACTIVE = 0x4000,
- UV__HANDLE_REF = 0x2000
+ UV__HANDLE_REF = 0x2000,
+ UV__HANDLE_CLOSING = 0 /* no-op on unix */
};
#else
# define UV__HANDLE_INTERNAL 0x80
# define UV__HANDLE_ACTIVE 0x40
# define UV__HANDLE_REF 0x20
+# define UV__HANDLE_CLOSING 0x01
#endif
extern const uv_err_t uv_ok_;
@@ -129,28 +131,32 @@ UNUSED static int uv__is_active(const uv_handle_t* h) {
UNUSED static void uv__handle_start(uv_handle_t* h) {
if (h->flags & UV__HANDLE_ACTIVE) return;
- if (h->flags & UV__HANDLE_REF) uv__active_handle_add(h);
h->flags |= UV__HANDLE_ACTIVE;
+ if (h->flags & UV__HANDLE_CLOSING) return;
+ if (h->flags & UV__HANDLE_REF) uv__active_handle_add(h);
}
#define uv__handle_start(h) uv__handle_start((uv_handle_t*)(h))
UNUSED static void uv__handle_stop(uv_handle_t* h) {
if (!(h->flags & UV__HANDLE_ACTIVE)) return;
- if (h->flags & UV__HANDLE_REF) uv__active_handle_rm(h);
h->flags &= ~UV__HANDLE_ACTIVE;
+ if (h->flags & UV__HANDLE_CLOSING) return;
+ if (h->flags & UV__HANDLE_REF) uv__active_handle_rm(h);
}
#define uv__handle_stop(h) uv__handle_stop((uv_handle_t*)(h))
UNUSED static void uv__handle_ref(uv_handle_t* h) {
if (h->flags & UV__HANDLE_REF) return;
- if (h->flags & UV__HANDLE_ACTIVE) uv__active_handle_add(h);
+ if (h->flags & (UV__HANDLE_ACTIVE | UV__HANDLE_CLOSING))
+ uv__active_handle_add(h);
h->flags |= UV__HANDLE_REF;
}
#define uv__handle_ref(h) uv__handle_ref((uv_handle_t*)(h))
UNUSED static void uv__handle_unref(uv_handle_t* h) {
if (!(h->flags & UV__HANDLE_REF)) return;
- if (h->flags & UV__HANDLE_ACTIVE) uv__active_handle_rm(h);
+ if (h->flags & (UV__HANDLE_ACTIVE | UV__HANDLE_CLOSING))
+ uv__active_handle_rm(h);
h->flags &= ~UV__HANDLE_REF;
}
#define uv__handle_unref(h) uv__handle_unref((uv_handle_t*)(h))
diff --git a/deps/uv/src/win/async.c b/deps/uv/src/win/async.c
index 40dee1fe9..4247c75a5 100644
--- a/deps/uv/src/win/async.c
+++ b/deps/uv/src/win/async.c
@@ -32,7 +32,6 @@ void uv_async_endgame(uv_loop_t* loop, uv_async_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING &&
!handle->async_sent) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
- uv__handle_stop(handle);
uv__handle_close(handle);
}
}
@@ -61,7 +60,7 @@ void uv_async_close(uv_loop_t* loop, uv_async_t* handle) {
uv_want_endgame(loop, (uv_handle_t*) handle);
}
- uv__handle_start(handle);
+ uv__handle_closing(handle);
}
diff --git a/deps/uv/src/win/fs-event.c b/deps/uv/src/win/fs-event.c
index 810be4f1e..0874a768a 100644
--- a/deps/uv/src/win/fs-event.c
+++ b/deps/uv/src/win/fs-event.c
@@ -470,7 +470,7 @@ void uv_fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle) {
uv_want_endgame(loop, (uv_handle_t*)handle);
}
- uv__handle_start(handle);
+ uv__handle_closing(handle);
}
@@ -478,7 +478,6 @@ void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING &&
!handle->req_pending) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
- uv__handle_stop(handle);
if (handle->buffer) {
_aligned_free(handle->buffer);
diff --git a/deps/uv/src/win/handle-inl.h b/deps/uv/src/win/handle-inl.h
index 18db5e69c..3b02b7f0a 100644
--- a/deps/uv/src/win/handle-inl.h
+++ b/deps/uv/src/win/handle-inl.h
@@ -59,12 +59,27 @@
} while (0)
+#define uv__handle_closing(handle) \
+ do { \
+ assert(!((handle)->flags & UV__HANDLE_CLOSING)); \
+ (handle)->flags |= UV__HANDLE_CLOSING; \
+ if ((handle)->flags & UV__HANDLE_ACTIVE) { \
+ (handle)->flags &= ~UV__HANDLE_ACTIVE; \
+ } else if ((handle)->flags & UV__HANDLE_REF) { \
+ uv__active_handle_add((uv_handle_t*) (handle)); \
+ } \
+ } while (0)
+
+
#define uv__handle_close(handle) \
do { \
ngx_queue_remove(&(handle)->handle_queue); \
(handle)->flags |= UV_HANDLE_CLOSED; \
+ if (handle->flags & UV__HANDLE_REF) { \
+ uv__active_handle_rm((uv_handle_t*) (handle)); \
+ } \
if ((handle)->close_cb) { \
- (handle)->close_cb((uv_handle_t*)(handle)); \
+ (handle)->close_cb((uv_handle_t*) (handle)); \
} \
} while (0)
diff --git a/deps/uv/src/win/handle.c b/deps/uv/src/win/handle.c
index 74bd56c09..d300bd2b6 100644
--- a/deps/uv/src/win/handle.c
+++ b/deps/uv/src/win/handle.c
@@ -71,7 +71,6 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) {
return;
}
- handle->flags |= UV_HANDLE_CLOSING;
handle->close_cb = cb;
/* Handle-specific close actions */
@@ -98,25 +97,25 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) {
case UV_TIMER:
uv_timer_stop((uv_timer_t*)handle);
- uv__handle_start(handle);
+ uv__handle_closing(handle);
uv_want_endgame(loop, handle);
return;
case UV_PREPARE:
uv_prepare_stop((uv_prepare_t*)handle);
- uv__handle_start(handle);
+ uv__handle_closing(handle);
uv_want_endgame(loop, handle);
return;
case UV_CHECK:
uv_check_stop((uv_check_t*)handle);
- uv__handle_start(handle);
+ uv__handle_closing(handle);
uv_want_endgame(loop, handle);
return;
case UV_IDLE:
uv_idle_stop((uv_idle_t*)handle);
- uv__handle_start(handle);
+ uv__handle_closing(handle);
uv_want_endgame(loop, handle);
return;
@@ -138,7 +137,7 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) {
case UV_FS_POLL:
uv__fs_poll_close((uv_fs_poll_t*) handle);
- uv__handle_start(handle);
+ uv__handle_closing(handle);
uv_want_endgame(loop, handle);
return;
diff --git a/deps/uv/src/win/loop-watcher.c b/deps/uv/src/win/loop-watcher.c
index 1a0286202..ee80feb96 100644
--- a/deps/uv/src/win/loop-watcher.c
+++ b/deps/uv/src/win/loop-watcher.c
@@ -30,7 +30,6 @@ void uv_loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
handle->flags |= UV_HANDLE_CLOSED;
- uv__handle_stop(handle);
uv__handle_close(handle);
}
}
diff --git a/deps/uv/src/win/pipe.c b/deps/uv/src/win/pipe.c
index a4bb7641b..62cdef544 100644
--- a/deps/uv/src/win/pipe.c
+++ b/deps/uv/src/win/pipe.c
@@ -357,7 +357,6 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING &&
handle->reqs_pending == 0) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
- uv__handle_stop(handle);
if (handle->flags & UV_HANDLE_CONNECTION) {
if (handle->pending_ipc_info.socket_info) {
@@ -660,7 +659,7 @@ void uv_pipe_close(uv_loop_t* loop, uv_pipe_t* handle) {
uv_want_endgame(loop, (uv_handle_t*) handle);
}
- uv__handle_start(handle);
+ uv__handle_closing(handle);
}
diff --git a/deps/uv/src/win/poll.c b/deps/uv/src/win/poll.c
index 308198949..c6feaae51 100644
--- a/deps/uv/src/win/poll.c
+++ b/deps/uv/src/win/poll.c
@@ -230,7 +230,7 @@ static int uv__fast_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) {
static void uv__fast_poll_close(uv_loop_t* loop, uv_poll_t* handle) {
handle->events = 0;
- uv__handle_start(handle);
+ uv__handle_closing(handle);
if (handle->submitted_events_1 == 0 &&
handle->submitted_events_2 == 0) {
@@ -477,7 +477,7 @@ static int uv__slow_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) {
static void uv__slow_poll_close(uv_loop_t* loop, uv_poll_t* handle) {
handle->events = 0;
- uv__handle_start(handle);
+ uv__handle_closing(handle);
if (handle->submitted_events_1 == 0 &&
handle->submitted_events_2 == 0) {
@@ -611,6 +611,5 @@ void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle) {
assert(handle->submitted_events_1 == 0);
assert(handle->submitted_events_2 == 0);
- uv__handle_stop(handle);
uv__handle_close(handle);
}
diff --git a/deps/uv/src/win/process.c b/deps/uv/src/win/process.c
index dac976907..884675876 100644
--- a/deps/uv/src/win/process.c
+++ b/deps/uv/src/win/process.c
@@ -700,7 +700,7 @@ void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle) {
void uv_process_close(uv_loop_t* loop, uv_process_t* handle) {
- uv__handle_start(handle);
+ uv__handle_closing(handle);
if (handle->wait_handle != INVALID_HANDLE_VALUE) {
/* This blocks until either the wait was cancelled, or the callback has */
@@ -725,8 +725,6 @@ void uv_process_endgame(uv_loop_t* loop, uv_process_t* handle) {
assert(handle->flags & UV_HANDLE_CLOSING);
assert(!(handle->flags & UV_HANDLE_CLOSED));
- uv__handle_stop(handle);
-
/* Clean-up the process handle. */
CloseHandle(handle->process_handle);
diff --git a/deps/uv/src/win/signal.c b/deps/uv/src/win/signal.c
index e35e1ff95..73aeff19b 100644
--- a/deps/uv/src/win/signal.c
+++ b/deps/uv/src/win/signal.c
@@ -231,8 +231,6 @@ int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle) {
req->type = UV_SIGNAL_REQ;
req->data = handle;
- uv__handle_start(handle);
-
return 0;
}
@@ -335,9 +333,9 @@ void uv_process_signal_req(uv_loop_t* loop, uv_signal_t* handle,
void uv_signal_close(uv_loop_t* loop, uv_signal_t* handle) {
uv_signal_stop(handle);
+ uv__handle_closing(handle);
if (handle->pending_signum == 0) {
- uv__handle_start(handle);
uv_want_endgame(loop, (uv_handle_t*) handle);
}
}
@@ -352,6 +350,5 @@ void uv_signal_endgame(uv_loop_t* loop, uv_signal_t* handle) {
handle->flags |= UV_HANDLE_CLOSED;
- uv__handle_stop(handle);
uv__handle_close(handle);
}
diff --git a/deps/uv/src/win/tcp.c b/deps/uv/src/win/tcp.c
index fdca4529a..4911cc62b 100644
--- a/deps/uv/src/win/tcp.c
+++ b/deps/uv/src/win/tcp.c
@@ -187,7 +187,6 @@ void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING &&
handle->reqs_pending == 0) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
- uv__handle_stop(handle);
if (!(handle->flags & UV_HANDLE_TCP_SOCKET_CLOSED)) {
closesocket(handle->socket);
@@ -1386,7 +1385,7 @@ void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp) {
tcp->flags |= UV_HANDLE_TCP_SOCKET_CLOSED;
}
- uv__handle_start(tcp);
+ uv__handle_closing(tcp);
if (tcp->reqs_pending == 0) {
uv_want_endgame(tcp->loop, (uv_handle_t*)tcp);
diff --git a/deps/uv/src/win/timer.c b/deps/uv/src/win/timer.c
index e9eab9aba..239f78843 100644
--- a/deps/uv/src/win/timer.c
+++ b/deps/uv/src/win/timer.c
@@ -78,7 +78,6 @@ int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) {
void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
- uv__handle_stop(handle);
uv__handle_close(handle);
}
}
diff --git a/deps/uv/src/win/tty.c b/deps/uv/src/win/tty.c
index af828cf8f..19edf7d29 100644
--- a/deps/uv/src/win/tty.c
+++ b/deps/uv/src/win/tty.c
@@ -527,11 +527,16 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
/* way that matters to libuv. */
if (handle->last_input_record.EventType == WINDOW_BUFFER_SIZE_EVENT) {
CONSOLE_SCREEN_BUFFER_INFO info;
- if (uv_tty_output_handle == INVALID_HANDLE_VALUE)
- continue;
- if (!GetConsoleScreenBufferInfo(uv_tty_output_handle, &info))
- continue;
- uv_tty_update_virtual_window(&info);
+
+ EnterCriticalSection(&uv_tty_output_lock);
+
+ if (uv_tty_output_handle != INVALID_HANDLE_VALUE &&
+ GetConsoleScreenBufferInfo(uv_tty_output_handle, &info)) {
+ uv_tty_update_virtual_window(&info);
+ }
+
+ LeaveCriticalSection(&uv_tty_output_lock);
+
continue;
}
@@ -1811,7 +1816,7 @@ void uv_tty_close(uv_tty_t* handle) {
handle->flags |= UV_HANDLE_SHUTTING;
}
- uv__handle_start(handle);
+ uv__handle_closing(handle);
if (handle->reqs_pending == 0) {
uv_want_endgame(handle->loop, (uv_handle_t*) handle);
@@ -1854,7 +1859,6 @@ void uv_tty_endgame(uv_loop_t* loop, uv_tty_t* handle) {
handle->read_raw_wait == NULL);
assert(!(handle->flags & UV_HANDLE_CLOSED));
- uv__handle_stop(handle);
uv__handle_close(handle);
}
}
diff --git a/deps/uv/src/win/udp.c b/deps/uv/src/win/udp.c
index 9ad2f69f4..5d3a54754 100644
--- a/deps/uv/src/win/udp.c
+++ b/deps/uv/src/win/udp.c
@@ -143,7 +143,7 @@ void uv_udp_close(uv_loop_t* loop, uv_udp_t* handle) {
uv_udp_recv_stop(handle);
closesocket(handle->socket);
- uv__handle_start(handle);
+ uv__handle_closing(handle);
if (handle->reqs_pending == 0) {
uv_want_endgame(loop, (uv_handle_t*) handle);
@@ -155,7 +155,6 @@ void uv_udp_endgame(uv_loop_t* loop, uv_udp_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING &&
handle->reqs_pending == 0) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
- uv__handle_stop(handle);
uv__handle_close(handle);
}
}
diff --git a/deps/uv/test/benchmark-list.h b/deps/uv/test/benchmark-list.h
index 5d59d4cf8..8b6efeef1 100644
--- a/deps/uv/test/benchmark-list.h
+++ b/deps/uv/test/benchmark-list.h
@@ -32,16 +32,31 @@ BENCHMARK_DECLARE (tcp_pump100_client)
BENCHMARK_DECLARE (tcp_pump1_client)
BENCHMARK_DECLARE (pipe_pump100_client)
BENCHMARK_DECLARE (pipe_pump1_client)
-BENCHMARK_DECLARE (udp_packet_storm_1v1)
-BENCHMARK_DECLARE (udp_packet_storm_1v10)
-BENCHMARK_DECLARE (udp_packet_storm_1v100)
-BENCHMARK_DECLARE (udp_packet_storm_1v1000)
-BENCHMARK_DECLARE (udp_packet_storm_10v10)
-BENCHMARK_DECLARE (udp_packet_storm_10v100)
-BENCHMARK_DECLARE (udp_packet_storm_10v1000)
-BENCHMARK_DECLARE (udp_packet_storm_100v100)
-BENCHMARK_DECLARE (udp_packet_storm_100v1000)
-BENCHMARK_DECLARE (udp_packet_storm_1000v1000)
+
+/* Run until X packets have been sent/received. */
+BENCHMARK_DECLARE (udp_pummel_1v1)
+BENCHMARK_DECLARE (udp_pummel_1v10)
+BENCHMARK_DECLARE (udp_pummel_1v100)
+BENCHMARK_DECLARE (udp_pummel_1v1000)
+BENCHMARK_DECLARE (udp_pummel_10v10)
+BENCHMARK_DECLARE (udp_pummel_10v100)
+BENCHMARK_DECLARE (udp_pummel_10v1000)
+BENCHMARK_DECLARE (udp_pummel_100v100)
+BENCHMARK_DECLARE (udp_pummel_100v1000)
+BENCHMARK_DECLARE (udp_pummel_1000v1000)
+
+/* Run until X seconds have elapsed. */
+BENCHMARK_DECLARE (udp_timed_pummel_1v1)
+BENCHMARK_DECLARE (udp_timed_pummel_1v10)
+BENCHMARK_DECLARE (udp_timed_pummel_1v100)
+BENCHMARK_DECLARE (udp_timed_pummel_1v1000)
+BENCHMARK_DECLARE (udp_timed_pummel_10v10)
+BENCHMARK_DECLARE (udp_timed_pummel_10v100)
+BENCHMARK_DECLARE (udp_timed_pummel_10v1000)
+BENCHMARK_DECLARE (udp_timed_pummel_100v100)
+BENCHMARK_DECLARE (udp_timed_pummel_100v1000)
+BENCHMARK_DECLARE (udp_timed_pummel_1000v1000)
+
BENCHMARK_DECLARE (getaddrinfo)
BENCHMARK_DECLARE (fs_stat)
BENCHMARK_DECLARE (async1)
@@ -97,16 +112,27 @@ TASK_LIST_START
BENCHMARK_ENTRY (pipe_pound_1000)
BENCHMARK_HELPER (pipe_pound_1000, pipe_echo_server)
- BENCHMARK_ENTRY (udp_packet_storm_1v1)
- BENCHMARK_ENTRY (udp_packet_storm_1v10)
- BENCHMARK_ENTRY (udp_packet_storm_1v100)
- BENCHMARK_ENTRY (udp_packet_storm_1v1000)
- BENCHMARK_ENTRY (udp_packet_storm_10v10)
- BENCHMARK_ENTRY (udp_packet_storm_10v100)
- BENCHMARK_ENTRY (udp_packet_storm_10v1000)
- BENCHMARK_ENTRY (udp_packet_storm_100v100)
- BENCHMARK_ENTRY (udp_packet_storm_100v1000)
- BENCHMARK_ENTRY (udp_packet_storm_1000v1000)
+ BENCHMARK_ENTRY (udp_pummel_1v1)
+ BENCHMARK_ENTRY (udp_pummel_1v10)
+ BENCHMARK_ENTRY (udp_pummel_1v100)
+ BENCHMARK_ENTRY (udp_pummel_1v1000)
+ BENCHMARK_ENTRY (udp_pummel_10v10)
+ BENCHMARK_ENTRY (udp_pummel_10v100)
+ BENCHMARK_ENTRY (udp_pummel_10v1000)
+ BENCHMARK_ENTRY (udp_pummel_100v100)
+ BENCHMARK_ENTRY (udp_pummel_100v1000)
+ BENCHMARK_ENTRY (udp_pummel_1000v1000)
+
+ BENCHMARK_ENTRY (udp_timed_pummel_1v1)
+ BENCHMARK_ENTRY (udp_timed_pummel_1v10)
+ BENCHMARK_ENTRY (udp_timed_pummel_1v100)
+ BENCHMARK_ENTRY (udp_timed_pummel_1v1000)
+ BENCHMARK_ENTRY (udp_timed_pummel_10v10)
+ BENCHMARK_ENTRY (udp_timed_pummel_10v100)
+ BENCHMARK_ENTRY (udp_timed_pummel_10v1000)
+ BENCHMARK_ENTRY (udp_timed_pummel_100v100)
+ BENCHMARK_ENTRY (udp_timed_pummel_100v1000)
+ BENCHMARK_ENTRY (udp_timed_pummel_1000v1000)
BENCHMARK_ENTRY (getaddrinfo)
diff --git a/deps/uv/test/benchmark-udp-packet-storm.c b/deps/uv/test/benchmark-udp-packet-storm.c
deleted file mode 100644
index 9842e4cea..000000000
--- a/deps/uv/test/benchmark-udp-packet-storm.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#include "task.h"
-#include "uv.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define EXPECTED "RANG TANG DING DONG I AM THE JAPANESE SANDMAN" /* "Take eight!" */
-
-#define TEST_DURATION 5000 /* ms */
-
-#define MAX_SENDERS 1000
-#define MAX_RECEIVERS 1000
-
-#define BASE_PORT 12345
-
-static uv_loop_t* loop;
-
-static int n_senders_;
-static int n_receivers_;
-static uv_udp_t senders[MAX_SENDERS];
-static uv_udp_t receivers[MAX_RECEIVERS];
-static uv_buf_t bufs[5];
-
-static int send_cb_called;
-static int recv_cb_called;
-static int close_cb_called;
-static int stopping = 0;
-
-typedef struct {
- struct sockaddr_in addr;
-} sender_state_t;
-
-
-static uv_buf_t alloc_cb(uv_handle_t* handle, size_t suggested_size) {
- static char slab[65536];
- ASSERT(suggested_size <= sizeof slab);
- return uv_buf_init(slab, sizeof slab);
-}
-
-
-static void send_cb(uv_udp_send_t* req, int status) {
- sender_state_t* ss;
- int r;
-
- if (stopping) {
- return;
- }
-
- ASSERT(req != NULL);
- ASSERT(status == 0);
-
- ss = req->data;
-
- r = uv_udp_send(req, req->handle, bufs, ARRAY_SIZE(bufs), ss->addr, send_cb);
- ASSERT(r == 0);
-
- req->data = ss;
-
- send_cb_called++;
-}
-
-
-static void recv_cb(uv_udp_t* handle,
- ssize_t nread,
- uv_buf_t buf,
- struct sockaddr* addr,
- unsigned flags) {
- if (nread == 0)
- return;
-
- if (nread == -1) {
- ASSERT(uv_last_error(loop).code == UV_ECANCELED);
- return;
- }
-
- ASSERT(addr->sa_family == AF_INET);
- ASSERT(!memcmp(buf.base, EXPECTED, nread));
-
- recv_cb_called++;
-}
-
-
-static void close_cb(uv_handle_t* handle) {
- ASSERT(handle != NULL);
- close_cb_called++;
-}
-
-
-static void timeout_cb(uv_timer_t* timer, int status) {
- int i;
-
- stopping = 1;
-
- for (i = 0; i < n_senders_; i++)
- uv_close((uv_handle_t*)&senders[i], close_cb);
-
- for (i = 0; i < n_receivers_; i++)
- uv_close((uv_handle_t*)&receivers[i], close_cb);
-}
-
-
-static int do_packet_storm(int n_senders, int n_receivers) {
- uv_timer_t timeout;
- sender_state_t *ss;
- uv_udp_send_t* req;
- uv_udp_t* handle;
- int i;
- int r;
-
- ASSERT(n_senders <= MAX_SENDERS);
- ASSERT(n_receivers <= MAX_RECEIVERS);
-
- loop = uv_default_loop();
-
- n_senders_ = n_senders;
- n_receivers_ = n_receivers;
-
- r = uv_timer_init(loop, &timeout);
- ASSERT(r == 0);
-
- r = uv_timer_start(&timeout, timeout_cb, TEST_DURATION, 0);
- ASSERT(r == 0);
-
- /* Timer should not keep loop alive. */
- uv_unref((uv_handle_t*)&timeout);
-
- for (i = 0; i < n_receivers; i++) {
- struct sockaddr_in addr;
- handle = &receivers[i];
-
- r = uv_udp_init(loop, handle);
- ASSERT(r == 0);
-
- addr = uv_ip4_addr("0.0.0.0", BASE_PORT + i);
-
- r = uv_udp_bind(handle, addr, 0);
- ASSERT(r == 0);
-
- r = uv_udp_recv_start(handle, alloc_cb, recv_cb);
- ASSERT(r == 0);
- }
-
- bufs[0] = uv_buf_init(EXPECTED + 0, 10);
- bufs[1] = uv_buf_init(EXPECTED + 10, 10);
- bufs[2] = uv_buf_init(EXPECTED + 20, 10);
- bufs[3] = uv_buf_init(EXPECTED + 30, 10);
- bufs[4] = uv_buf_init(EXPECTED + 40, 5);
-
- for (i = 0; i < n_senders; i++) {
- handle = &senders[i];
-
- r = uv_udp_init(loop, handle);
- ASSERT(r == 0);
-
- req = malloc(sizeof(*req) + sizeof(*ss));
-
- ss = (void*)(req + 1);
- ss->addr = uv_ip4_addr("127.0.0.1", BASE_PORT + (i % n_receivers));
-
- r = uv_udp_send(req, handle, bufs, ARRAY_SIZE(bufs), ss->addr, send_cb);
- ASSERT(r == 0);
-
- req->data = ss;
- }
-
- uv_run(loop);
-
- printf("udp_packet_storm_%dv%d: %.0f/s received, %.0f/s sent\n",
- n_receivers,
- n_senders,
- recv_cb_called / (TEST_DURATION / 1000.0),
- send_cb_called / (TEST_DURATION / 1000.0));
-
- return 0;
-}
-
-
-BENCHMARK_IMPL(udp_packet_storm_1v1) {
- return do_packet_storm(1, 1);
-}
-
-
-BENCHMARK_IMPL(udp_packet_storm_1v10) {
- return do_packet_storm(1, 10);
-}
-
-
-BENCHMARK_IMPL(udp_packet_storm_1v100) {
- return do_packet_storm(1, 100);
-}
-
-
-BENCHMARK_IMPL(udp_packet_storm_1v1000) {
- return do_packet_storm(1, 1000);
-}
-
-
-BENCHMARK_IMPL(udp_packet_storm_10v10) {
- return do_packet_storm(10, 10);
-}
-
-
-BENCHMARK_IMPL(udp_packet_storm_10v100) {
- return do_packet_storm(10, 100);
-}
-
-
-BENCHMARK_IMPL(udp_packet_storm_10v1000) {
- return do_packet_storm(10, 1000);
-}
-
-
-BENCHMARK_IMPL(udp_packet_storm_100v100) {
- return do_packet_storm(100, 100);
-}
-
-
-BENCHMARK_IMPL(udp_packet_storm_100v1000) {
- return do_packet_storm(100, 1000);
-}
-
-
-BENCHMARK_IMPL(udp_packet_storm_1000v1000) {
- return do_packet_storm(1000, 1000);
-}
diff --git a/deps/uv/test/benchmark-udp-pummel.c b/deps/uv/test/benchmark-udp-pummel.c
new file mode 100644
index 000000000..1a186c27e
--- /dev/null
+++ b/deps/uv/test/benchmark-udp-pummel.c
@@ -0,0 +1,229 @@
+/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "task.h"
+#include "uv.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define EXPECTED "RANG TANG DING DONG I AM THE JAPANESE SANDMAN" /* "Take eight!" */
+
+#define TEST_DURATION 5000 /* ms */
+
+#define BASE_PORT 12345
+
+struct sender_state {
+ struct sockaddr_in addr;
+ uv_udp_send_t send_req;
+ uv_udp_t udp_handle;
+};
+
+struct receiver_state {
+ struct sockaddr_in addr;
+ uv_udp_t udp_handle;
+};
+
+static unsigned int packet_counter = 1e6; /* not used in timed mode */
+
+static int n_senders_;
+static int n_receivers_;
+static uv_buf_t bufs[5];
+static struct sender_state senders[1024];
+static struct receiver_state receivers[1024];
+
+static unsigned int send_cb_called;
+static unsigned int recv_cb_called;
+static unsigned int close_cb_called;
+static int timed;
+
+
+static uv_buf_t alloc_cb(uv_handle_t* handle, size_t suggested_size) {
+ static char slab[65536];
+ ASSERT(suggested_size <= sizeof slab);
+ return uv_buf_init(slab, sizeof slab);
+}
+
+
+static void send_cb(uv_udp_send_t* req, int status) {
+ struct sender_state* s;
+
+ ASSERT(req != NULL);
+
+ if (status != 0) {
+ ASSERT(status == -1);
+ ASSERT(uv_last_error(req->handle->loop).code == UV_EINTR);
+ return;
+ }
+
+ s = container_of(req, struct sender_state, send_req);
+ ASSERT(req->handle == &s->udp_handle);
+
+ if (timed)
+ goto send;
+
+ if (packet_counter == 0) {
+ uv_close((uv_handle_t*)&s->udp_handle, NULL);
+ return;
+ }
+
+ packet_counter--;
+
+send:
+ ASSERT(0 == uv_udp_send(&s->send_req,
+ &s->udp_handle,
+ bufs,
+ ARRAY_SIZE(bufs),
+ s->addr,
+ send_cb));
+ send_cb_called++;
+}
+
+
+static void recv_cb(uv_udp_t* handle,
+ ssize_t nread,
+ uv_buf_t buf,
+ struct sockaddr* addr,
+ unsigned flags) {
+ if (nread == 0)
+ return;
+
+ if (nread == -1) {
+ ASSERT(uv_last_error(handle->loop).code == UV_ECANCELED);
+ return;
+ }
+
+ ASSERT(addr->sa_family == AF_INET);
+ ASSERT(!memcmp(buf.base, EXPECTED, nread));
+
+ recv_cb_called++;
+}
+
+
+static void close_cb(uv_handle_t* handle) {
+ ASSERT(handle != NULL);
+ close_cb_called++;
+}
+
+
+static void timeout_cb(uv_timer_t* timer, int status) {
+ int i;
+
+ for (i = 0; i < n_senders_; i++)
+ uv_close((uv_handle_t*)&senders[i].udp_handle, close_cb);
+
+ for (i = 0; i < n_receivers_; i++)
+ uv_close((uv_handle_t*)&receivers[i].udp_handle, close_cb);
+}
+
+
+static int do_packet_storm(int n_senders,
+ int n_receivers,
+ unsigned long timeout) {
+ uv_timer_t timer_handle;
+ uint64_t duration;
+ uv_loop_t* loop;
+ int i;
+
+ ASSERT(n_senders <= ARRAY_SIZE(senders));
+ ASSERT(n_receivers <= ARRAY_SIZE(receivers));
+
+ loop = uv_default_loop();
+
+ n_senders_ = n_senders;
+ n_receivers_ = n_receivers;
+
+ if (timeout) {
+ ASSERT(0 == uv_timer_init(loop, &timer_handle));
+ ASSERT(0 == uv_timer_start(&timer_handle, timeout_cb, timeout, 0));
+ /* Timer should not keep loop alive. */
+ uv_unref((uv_handle_t*)&timer_handle);
+ timed = 1;
+ }
+
+ for (i = 0; i < n_receivers; i++) {
+ struct receiver_state* s = receivers + i;
+ struct sockaddr_in addr = uv_ip4_addr("0.0.0.0", BASE_PORT + i);
+ ASSERT(0 == uv_udp_init(loop, &s->udp_handle));
+ ASSERT(0 == uv_udp_bind(&s->udp_handle, addr, 0));
+ ASSERT(0 == uv_udp_recv_start(&s->udp_handle, alloc_cb, recv_cb));
+ uv_unref((uv_handle_t*)&s->udp_handle);
+ }
+
+ bufs[0] = uv_buf_init(EXPECTED + 0, 10);
+ bufs[1] = uv_buf_init(EXPECTED + 10, 10);
+ bufs[2] = uv_buf_init(EXPECTED + 20, 10);
+ bufs[3] = uv_buf_init(EXPECTED + 30, 10);
+ bufs[4] = uv_buf_init(EXPECTED + 40, 5);
+
+ for (i = 0; i < n_senders; i++) {
+ struct sender_state* s = senders + i;
+ s->addr = uv_ip4_addr("127.0.0.1", BASE_PORT + (i % n_receivers));
+ ASSERT(0 == uv_udp_init(loop, &s->udp_handle));
+ ASSERT(0 == uv_udp_send(&s->send_req,
+ &s->udp_handle,
+ bufs,
+ ARRAY_SIZE(bufs),
+ s->addr,
+ send_cb));
+ }
+
+ duration = uv_hrtime();
+ ASSERT(0 == uv_run(loop));
+ duration = uv_hrtime() - duration;
+ duration = duration / 1e6; /* convert from nanoseconds to milliseconds */
+
+ printf("udp_packet_storm_%dv%d: %.0f/s received, %.0f/s sent. "
+ "%u received, %u sent in %.1f seconds.\n",
+ n_receivers,
+ n_senders,
+ recv_cb_called / (duration / 1000.0),
+ send_cb_called / (duration / 1000.0),
+ recv_cb_called,
+ send_cb_called,
+ duration / 1000.0);
+
+ return 0;
+}
+
+
+#define X(a, b) \
+ BENCHMARK_IMPL(udp_pummel_##a##v##b) { \
+ return do_packet_storm(a, b, 0); \
+ } \
+ BENCHMARK_IMPL(udp_timed_pummel_##a##v##b) { \
+ return do_packet_storm(a, b, TEST_DURATION); \
+ }
+
+X(1, 1)
+X(1, 10)
+X(1, 100)
+X(1, 1000)
+X(10, 10)
+X(10, 100)
+X(10, 1000)
+X(100, 10)
+X(100, 100)
+X(100, 1000)
+X(1000, 1000)
+
+#undef X
diff --git a/deps/uv/test/test-active.c b/deps/uv/test/test-active.c
new file mode 100644
index 000000000..9af4fd669
--- /dev/null
+++ b/deps/uv/test/test-active.c
@@ -0,0 +1,82 @@
+/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "uv.h"
+#include "task.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static int close_cb_called = 0;
+
+
+static void close_cb(uv_handle_t* handle) {
+ ASSERT(handle != NULL);
+ close_cb_called++;
+}
+
+
+static void timer_cb(uv_timer_t* handle, int status) {
+ ASSERT(0 && "timer_cb should not have been called");
+}
+
+
+TEST_IMPL(active) {
+ int r;
+ uv_timer_t timer;
+
+ r = uv_timer_init(uv_default_loop(), &timer);
+ ASSERT(r == 0);
+
+ ASSERT(!uv_is_active((uv_handle_t*) &timer));
+ ASSERT(!uv_is_closing((uv_handle_t*) &timer));
+
+ r = uv_timer_start(&timer, timer_cb, 1000, 0);
+ ASSERT(r == 0);
+
+ ASSERT(uv_is_active((uv_handle_t*) &timer));
+ ASSERT(!uv_is_closing((uv_handle_t*) &timer));
+
+ r = uv_timer_stop(&timer);
+ ASSERT(r == 0);
+
+ ASSERT(!uv_is_active((uv_handle_t*) &timer));
+ ASSERT(!uv_is_closing((uv_handle_t*) &timer));
+
+ r = uv_timer_start(&timer, timer_cb, 1000, 0);
+ ASSERT(r == 0);
+
+ ASSERT(uv_is_active((uv_handle_t*) &timer));
+ ASSERT(!uv_is_closing((uv_handle_t*) &timer));
+
+ uv_close((uv_handle_t*) &timer, close_cb);
+
+ ASSERT(!uv_is_active((uv_handle_t*) &timer));
+ ASSERT(uv_is_closing((uv_handle_t*) &timer));
+
+ r = uv_run(uv_default_loop());
+ ASSERT(r == 0);
+
+ ASSERT(close_cb_called == 1);
+
+ return 0;
+}
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index 47e47eedd..1423f806a 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -111,6 +111,7 @@ TEST_DECLARE (pipe_ref2)
TEST_DECLARE (pipe_ref3)
TEST_DECLARE (pipe_ref4)
TEST_DECLARE (process_ref)
+TEST_DECLARE (active)
TEST_DECLARE (async)
TEST_DECLARE (get_currentexe)
TEST_DECLARE (process_title)
@@ -328,6 +329,8 @@ TASK_LIST_START
TEST_ENTRY (loop_handles)
TEST_ENTRY (walk_handles)
+ TEST_ENTRY (active)
+
TEST_ENTRY (async)
TEST_ENTRY (get_currentexe)
diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp
index 7b0fe1a57..8ce01ebfd 100644
--- a/deps/uv/uv.gyp
+++ b/deps/uv/uv.gyp
@@ -228,13 +228,14 @@
'test/test-get-loadavg.c',
'test/task.h',
'test/test-util.c',
+ 'test/test-active.c',
'test/test-async.c',
- 'test/test-error.c',
'test/test-callback-stack.c',
'test/test-callback-order.c',
'test/test-connection-fail.c',
'test/test-cwd-and-chdir.c',
'test/test-delayed-accept.c',
+ 'test/test-error.c',
'test/test-fail-always.c',
'test/test-fs.c',
'test/test-fs-event.c',
@@ -343,7 +344,7 @@
'test/benchmark-spawn.c',
'test/benchmark-thread.c',
'test/benchmark-tcp-write-batch.c',
- 'test/benchmark-udp-packet-storm.c',
+ 'test/benchmark-udp-pummel.c',
'test/dns-server.c',
'test/echo-server.c',
'test/blackhole-server.c',