Browse Source

uv: upgrade to 621a4e3

v0.9.1-release
Bert Belder 13 years ago
parent
commit
4822d780bb
  1. 6
      deps/uv/include/uv-private/uv-win.h
  2. 3
      deps/uv/include/uv.h
  3. 1
      deps/uv/src/fs-poll.c
  4. 2
      deps/uv/src/unix/async.c
  5. 1
      deps/uv/src/unix/error.c
  6. 3
      deps/uv/src/unix/linux/linux-core.c
  7. 15
      deps/uv/src/unix/stream.c
  8. 13
      deps/uv/src/unix/thread.c
  9. 7
      deps/uv/src/unix/udp.c
  10. 16
      deps/uv/src/uv-common.h
  11. 3
      deps/uv/src/win/async.c
  12. 3
      deps/uv/src/win/fs-event.c
  13. 15
      deps/uv/src/win/handle-inl.h
  14. 11
      deps/uv/src/win/handle.c
  15. 1
      deps/uv/src/win/loop-watcher.c
  16. 3
      deps/uv/src/win/pipe.c
  17. 5
      deps/uv/src/win/poll.c
  18. 4
      deps/uv/src/win/process.c
  19. 5
      deps/uv/src/win/signal.c
  20. 3
      deps/uv/src/win/tcp.c
  21. 1
      deps/uv/src/win/timer.c
  22. 16
      deps/uv/src/win/tty.c
  23. 3
      deps/uv/src/win/udp.c
  24. 66
      deps/uv/test/benchmark-list.h
  25. 247
      deps/uv/test/benchmark-udp-packet-storm.c
  26. 229
      deps/uv/test/benchmark-udp-pummel.c
  27. 82
      deps/uv/test/test-active.c
  28. 3
      deps/uv/test/test-list.h
  29. 5
      deps/uv/uv.gyp

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

@ -67,6 +67,12 @@ typedef intptr_t ssize_t;
#define SIGKILL 9 #define SIGKILL 9
#define SIGWINCH 28 #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 * Guids and typedefs for winsock extension functions
* Mingw32 doesn't have these :-( * Mingw32 doesn't have these :-(

3
deps/uv/include/uv.h

@ -122,7 +122,8 @@ extern "C" {
XX( 55, EIO, "i/o error") \ XX( 55, EIO, "i/o error") \
XX( 56, EROFS, "read-only file system") \ XX( 56, EROFS, "read-only file system") \
XX( 57, ENODEV, "no such device") \ XX( 57, ENODEV, "no such device") \
XX( 58, ECANCELED, "operation canceled" ) XX( 58, ESPIPE, "invalid seek") \
XX( 59, ECANCELED, "operation canceled") \
#define UV_ERRNO_GEN(val, name, s) UV_##name = val, #define UV_ERRNO_GEN(val, name, s) UV_##name = val,

1
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) { 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_CLOSING);
assert(!(handle->flags & UV_HANDLE_CLOSED)); assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_stop(handle);
uv__handle_close(handle); uv__handle_close(handle);
} }

2
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; return __sync_val_compare_and_swap(ptr, 0, 1) != 0;
#else #else
*ptr = 1; *ptr = 1;
return 1; return 0;
#endif #endif
} }

1
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 EAFNOSUPPORT: return UV_EAFNOSUPPORT;
case EBADF: return UV_EBADF; case EBADF: return UV_EBADF;
case EPIPE: return UV_EPIPE; case EPIPE: return UV_EPIPE;
case ESPIPE: return UV_ESPIPE;
case EAGAIN: return UV_EAGAIN; case EAGAIN: return UV_EAGAIN;
#if EWOULDBLOCK != EAGAIN #if EWOULDBLOCK != EAGAIN
case EWOULDBLOCK: return UV_EAGAIN; case EWOULDBLOCK: return UV_EAGAIN;

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

@ -469,8 +469,9 @@ static unsigned long read_cpufreq(unsigned int cpunum) {
if (fp == NULL) if (fp == NULL)
return 0; return 0;
if (fscanf(fp, "%lu", &val) != 1)
val = 0; val = 0;
fscanf(fp, "%lu", &val);
fclose(fp); fclose(fp);
return val; return val;

15
deps/uv/src/unix/stream.c

@ -655,7 +655,13 @@ start:
cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS; cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = msg.msg_controllen; 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 { do {
n = sendmsg(stream->fd, &msg, 0); 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"); 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 { } else {
fprintf(stderr, "ignoring non-SCM_RIGHTS ancillary data: %d\n", fprintf(stderr, "ignoring non-SCM_RIGHTS ancillary data: %d\n",

13
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__) #if defined(__APPLE__) && defined(__MACH__)
int uv_sem_init(uv_sem_t* sem, unsigned int value) { 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) { 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(); abort();
} }

7
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); req = ngx_queue_data(q, uv_udp_send_t, queue);
uv__req_unregister(handle->loop, req); uv__req_unregister(handle->loop, req);
if (req->bufs != req->bufsml)
free(req->bufs);
req->bufs = NULL;
if (req->send_cb) { if (req->send_cb) {
/* FIXME proper error code like UV_EABORTED */ /* FIXME proper error code like UV_EABORTED */
uv__set_artificial_error(handle->loop, UV_EINTR); 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) if (req->bufs != req->bufsml)
free(req->bufs); free(req->bufs);
req->bufs = NULL;
if (req->send_cb == NULL) if (req->send_cb == NULL)
continue; continue;
@ -375,7 +380,7 @@ out:
static int uv__udp_maybe_deferred_bind(uv_udp_t* handle, int domain) { 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; socklen_t addrlen;
assert(domain == AF_INET || domain == AF_INET6); assert(domain == AF_INET || domain == AF_INET6);

16
deps/uv/src/uv-common.h

@ -53,12 +53,14 @@
enum { enum {
UV__HANDLE_INTERNAL = 0x8000, UV__HANDLE_INTERNAL = 0x8000,
UV__HANDLE_ACTIVE = 0x4000, UV__HANDLE_ACTIVE = 0x4000,
UV__HANDLE_REF = 0x2000 UV__HANDLE_REF = 0x2000,
UV__HANDLE_CLOSING = 0 /* no-op on unix */
}; };
#else #else
# define UV__HANDLE_INTERNAL 0x80 # define UV__HANDLE_INTERNAL 0x80
# define UV__HANDLE_ACTIVE 0x40 # define UV__HANDLE_ACTIVE 0x40
# define UV__HANDLE_REF 0x20 # define UV__HANDLE_REF 0x20
# define UV__HANDLE_CLOSING 0x01
#endif #endif
extern const uv_err_t uv_ok_; 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) { UNUSED static void uv__handle_start(uv_handle_t* h) {
if (h->flags & UV__HANDLE_ACTIVE) return; if (h->flags & UV__HANDLE_ACTIVE) return;
if (h->flags & UV__HANDLE_REF) uv__active_handle_add(h);
h->flags |= UV__HANDLE_ACTIVE; 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)) #define uv__handle_start(h) uv__handle_start((uv_handle_t*)(h))
UNUSED static void uv__handle_stop(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_ACTIVE)) return;
if (h->flags & UV__HANDLE_REF) uv__active_handle_rm(h);
h->flags &= ~UV__HANDLE_ACTIVE; 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)) #define uv__handle_stop(h) uv__handle_stop((uv_handle_t*)(h))
UNUSED static void uv__handle_ref(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_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; h->flags |= UV__HANDLE_REF;
} }
#define uv__handle_ref(h) uv__handle_ref((uv_handle_t*)(h)) #define uv__handle_ref(h) uv__handle_ref((uv_handle_t*)(h))
UNUSED static void uv__handle_unref(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_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; h->flags &= ~UV__HANDLE_REF;
} }
#define uv__handle_unref(h) uv__handle_unref((uv_handle_t*)(h)) #define uv__handle_unref(h) uv__handle_unref((uv_handle_t*)(h))

3
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 && if (handle->flags & UV_HANDLE_CLOSING &&
!handle->async_sent) { !handle->async_sent) {
assert(!(handle->flags & UV_HANDLE_CLOSED)); assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_stop(handle);
uv__handle_close(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_want_endgame(loop, (uv_handle_t*) handle);
} }
uv__handle_start(handle); uv__handle_closing(handle);
} }

3
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_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 && if (handle->flags & UV_HANDLE_CLOSING &&
!handle->req_pending) { !handle->req_pending) {
assert(!(handle->flags & UV_HANDLE_CLOSED)); assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_stop(handle);
if (handle->buffer) { if (handle->buffer) {
_aligned_free(handle->buffer); _aligned_free(handle->buffer);

15
deps/uv/src/win/handle-inl.h

@ -59,10 +59,25 @@
} while (0) } 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) \ #define uv__handle_close(handle) \
do { \ do { \
ngx_queue_remove(&(handle)->handle_queue); \ ngx_queue_remove(&(handle)->handle_queue); \
(handle)->flags |= UV_HANDLE_CLOSED; \ (handle)->flags |= UV_HANDLE_CLOSED; \
if (handle->flags & UV__HANDLE_REF) { \
uv__active_handle_rm((uv_handle_t*) (handle)); \
} \
if ((handle)->close_cb) { \ if ((handle)->close_cb) { \
(handle)->close_cb((uv_handle_t*) (handle)); \ (handle)->close_cb((uv_handle_t*) (handle)); \
} \ } \

11
deps/uv/src/win/handle.c

@ -71,7 +71,6 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) {
return; return;
} }
handle->flags |= UV_HANDLE_CLOSING;
handle->close_cb = cb; handle->close_cb = cb;
/* Handle-specific close actions */ /* Handle-specific close actions */
@ -98,25 +97,25 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) {
case UV_TIMER: case UV_TIMER:
uv_timer_stop((uv_timer_t*)handle); uv_timer_stop((uv_timer_t*)handle);
uv__handle_start(handle); uv__handle_closing(handle);
uv_want_endgame(loop, handle); uv_want_endgame(loop, handle);
return; return;
case UV_PREPARE: case UV_PREPARE:
uv_prepare_stop((uv_prepare_t*)handle); uv_prepare_stop((uv_prepare_t*)handle);
uv__handle_start(handle); uv__handle_closing(handle);
uv_want_endgame(loop, handle); uv_want_endgame(loop, handle);
return; return;
case UV_CHECK: case UV_CHECK:
uv_check_stop((uv_check_t*)handle); uv_check_stop((uv_check_t*)handle);
uv__handle_start(handle); uv__handle_closing(handle);
uv_want_endgame(loop, handle); uv_want_endgame(loop, handle);
return; return;
case UV_IDLE: case UV_IDLE:
uv_idle_stop((uv_idle_t*)handle); uv_idle_stop((uv_idle_t*)handle);
uv__handle_start(handle); uv__handle_closing(handle);
uv_want_endgame(loop, handle); uv_want_endgame(loop, handle);
return; return;
@ -138,7 +137,7 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) {
case UV_FS_POLL: case UV_FS_POLL:
uv__fs_poll_close((uv_fs_poll_t*) handle); uv__fs_poll_close((uv_fs_poll_t*) handle);
uv__handle_start(handle); uv__handle_closing(handle);
uv_want_endgame(loop, handle); uv_want_endgame(loop, handle);
return; return;

1
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) { if (handle->flags & UV_HANDLE_CLOSING) {
assert(!(handle->flags & UV_HANDLE_CLOSED)); assert(!(handle->flags & UV_HANDLE_CLOSED));
handle->flags |= UV_HANDLE_CLOSED; handle->flags |= UV_HANDLE_CLOSED;
uv__handle_stop(handle);
uv__handle_close(handle); uv__handle_close(handle);
} }
} }

3
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 && if (handle->flags & UV_HANDLE_CLOSING &&
handle->reqs_pending == 0) { handle->reqs_pending == 0) {
assert(!(handle->flags & UV_HANDLE_CLOSED)); assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_stop(handle);
if (handle->flags & UV_HANDLE_CONNECTION) { if (handle->flags & UV_HANDLE_CONNECTION) {
if (handle->pending_ipc_info.socket_info) { 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_want_endgame(loop, (uv_handle_t*) handle);
} }
uv__handle_start(handle); uv__handle_closing(handle);
} }

5
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) { static void uv__fast_poll_close(uv_loop_t* loop, uv_poll_t* handle) {
handle->events = 0; handle->events = 0;
uv__handle_start(handle); uv__handle_closing(handle);
if (handle->submitted_events_1 == 0 && if (handle->submitted_events_1 == 0 &&
handle->submitted_events_2 == 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) { static void uv__slow_poll_close(uv_loop_t* loop, uv_poll_t* handle) {
handle->events = 0; handle->events = 0;
uv__handle_start(handle); uv__handle_closing(handle);
if (handle->submitted_events_1 == 0 && if (handle->submitted_events_1 == 0 &&
handle->submitted_events_2 == 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_1 == 0);
assert(handle->submitted_events_2 == 0); assert(handle->submitted_events_2 == 0);
uv__handle_stop(handle);
uv__handle_close(handle); uv__handle_close(handle);
} }

4
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) { 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) { if (handle->wait_handle != INVALID_HANDLE_VALUE) {
/* This blocks until either the wait was cancelled, or the callback has */ /* 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_CLOSING);
assert(!(handle->flags & UV_HANDLE_CLOSED)); assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_stop(handle);
/* Clean-up the process handle. */ /* Clean-up the process handle. */
CloseHandle(handle->process_handle); CloseHandle(handle->process_handle);

5
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->type = UV_SIGNAL_REQ;
req->data = handle; req->data = handle;
uv__handle_start(handle);
return 0; 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) { void uv_signal_close(uv_loop_t* loop, uv_signal_t* handle) {
uv_signal_stop(handle); uv_signal_stop(handle);
uv__handle_closing(handle);
if (handle->pending_signum == 0) { if (handle->pending_signum == 0) {
uv__handle_start(handle);
uv_want_endgame(loop, (uv_handle_t*) 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; handle->flags |= UV_HANDLE_CLOSED;
uv__handle_stop(handle);
uv__handle_close(handle); uv__handle_close(handle);
} }

3
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 && if (handle->flags & UV_HANDLE_CLOSING &&
handle->reqs_pending == 0) { handle->reqs_pending == 0) {
assert(!(handle->flags & UV_HANDLE_CLOSED)); assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_stop(handle);
if (!(handle->flags & UV_HANDLE_TCP_SOCKET_CLOSED)) { if (!(handle->flags & UV_HANDLE_TCP_SOCKET_CLOSED)) {
closesocket(handle->socket); 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; tcp->flags |= UV_HANDLE_TCP_SOCKET_CLOSED;
} }
uv__handle_start(tcp); uv__handle_closing(tcp);
if (tcp->reqs_pending == 0) { if (tcp->reqs_pending == 0) {
uv_want_endgame(tcp->loop, (uv_handle_t*)tcp); uv_want_endgame(tcp->loop, (uv_handle_t*)tcp);

1
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) { void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle) {
if (handle->flags & UV_HANDLE_CLOSING) { if (handle->flags & UV_HANDLE_CLOSING) {
assert(!(handle->flags & UV_HANDLE_CLOSED)); assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_stop(handle);
uv__handle_close(handle); uv__handle_close(handle);
} }
} }

16
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. */ /* way that matters to libuv. */
if (handle->last_input_record.EventType == WINDOW_BUFFER_SIZE_EVENT) { if (handle->last_input_record.EventType == WINDOW_BUFFER_SIZE_EVENT) {
CONSOLE_SCREEN_BUFFER_INFO info; CONSOLE_SCREEN_BUFFER_INFO info;
if (uv_tty_output_handle == INVALID_HANDLE_VALUE)
continue; EnterCriticalSection(&uv_tty_output_lock);
if (!GetConsoleScreenBufferInfo(uv_tty_output_handle, &info))
continue; if (uv_tty_output_handle != INVALID_HANDLE_VALUE &&
GetConsoleScreenBufferInfo(uv_tty_output_handle, &info)) {
uv_tty_update_virtual_window(&info); uv_tty_update_virtual_window(&info);
}
LeaveCriticalSection(&uv_tty_output_lock);
continue; continue;
} }
@ -1811,7 +1816,7 @@ void uv_tty_close(uv_tty_t* handle) {
handle->flags |= UV_HANDLE_SHUTTING; handle->flags |= UV_HANDLE_SHUTTING;
} }
uv__handle_start(handle); uv__handle_closing(handle);
if (handle->reqs_pending == 0) { if (handle->reqs_pending == 0) {
uv_want_endgame(handle->loop, (uv_handle_t*) handle); 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); handle->read_raw_wait == NULL);
assert(!(handle->flags & UV_HANDLE_CLOSED)); assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_stop(handle);
uv__handle_close(handle); uv__handle_close(handle);
} }
} }

3
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); uv_udp_recv_stop(handle);
closesocket(handle->socket); closesocket(handle->socket);
uv__handle_start(handle); uv__handle_closing(handle);
if (handle->reqs_pending == 0) { if (handle->reqs_pending == 0) {
uv_want_endgame(loop, (uv_handle_t*) handle); 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 && if (handle->flags & UV_HANDLE_CLOSING &&
handle->reqs_pending == 0) { handle->reqs_pending == 0) {
assert(!(handle->flags & UV_HANDLE_CLOSED)); assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_stop(handle);
uv__handle_close(handle); uv__handle_close(handle);
} }
} }

66
deps/uv/test/benchmark-list.h

@ -32,16 +32,31 @@ BENCHMARK_DECLARE (tcp_pump100_client)
BENCHMARK_DECLARE (tcp_pump1_client) BENCHMARK_DECLARE (tcp_pump1_client)
BENCHMARK_DECLARE (pipe_pump100_client) BENCHMARK_DECLARE (pipe_pump100_client)
BENCHMARK_DECLARE (pipe_pump1_client) BENCHMARK_DECLARE (pipe_pump1_client)
BENCHMARK_DECLARE (udp_packet_storm_1v1)
BENCHMARK_DECLARE (udp_packet_storm_1v10) /* Run until X packets have been sent/received. */
BENCHMARK_DECLARE (udp_packet_storm_1v100) BENCHMARK_DECLARE (udp_pummel_1v1)
BENCHMARK_DECLARE (udp_packet_storm_1v1000) BENCHMARK_DECLARE (udp_pummel_1v10)
BENCHMARK_DECLARE (udp_packet_storm_10v10) BENCHMARK_DECLARE (udp_pummel_1v100)
BENCHMARK_DECLARE (udp_packet_storm_10v100) BENCHMARK_DECLARE (udp_pummel_1v1000)
BENCHMARK_DECLARE (udp_packet_storm_10v1000) BENCHMARK_DECLARE (udp_pummel_10v10)
BENCHMARK_DECLARE (udp_packet_storm_100v100) BENCHMARK_DECLARE (udp_pummel_10v100)
BENCHMARK_DECLARE (udp_packet_storm_100v1000) BENCHMARK_DECLARE (udp_pummel_10v1000)
BENCHMARK_DECLARE (udp_packet_storm_1000v1000) 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 (getaddrinfo)
BENCHMARK_DECLARE (fs_stat) BENCHMARK_DECLARE (fs_stat)
BENCHMARK_DECLARE (async1) BENCHMARK_DECLARE (async1)
@ -97,16 +112,27 @@ TASK_LIST_START
BENCHMARK_ENTRY (pipe_pound_1000) BENCHMARK_ENTRY (pipe_pound_1000)
BENCHMARK_HELPER (pipe_pound_1000, pipe_echo_server) BENCHMARK_HELPER (pipe_pound_1000, pipe_echo_server)
BENCHMARK_ENTRY (udp_packet_storm_1v1) BENCHMARK_ENTRY (udp_pummel_1v1)
BENCHMARK_ENTRY (udp_packet_storm_1v10) BENCHMARK_ENTRY (udp_pummel_1v10)
BENCHMARK_ENTRY (udp_packet_storm_1v100) BENCHMARK_ENTRY (udp_pummel_1v100)
BENCHMARK_ENTRY (udp_packet_storm_1v1000) BENCHMARK_ENTRY (udp_pummel_1v1000)
BENCHMARK_ENTRY (udp_packet_storm_10v10) BENCHMARK_ENTRY (udp_pummel_10v10)
BENCHMARK_ENTRY (udp_packet_storm_10v100) BENCHMARK_ENTRY (udp_pummel_10v100)
BENCHMARK_ENTRY (udp_packet_storm_10v1000) BENCHMARK_ENTRY (udp_pummel_10v1000)
BENCHMARK_ENTRY (udp_packet_storm_100v100) BENCHMARK_ENTRY (udp_pummel_100v100)
BENCHMARK_ENTRY (udp_packet_storm_100v1000) BENCHMARK_ENTRY (udp_pummel_100v1000)
BENCHMARK_ENTRY (udp_packet_storm_1000v1000) 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) BENCHMARK_ENTRY (getaddrinfo)

247
deps/uv/test/benchmark-udp-packet-storm.c

@ -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);
}

229
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

82
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;
}

3
deps/uv/test/test-list.h

@ -111,6 +111,7 @@ TEST_DECLARE (pipe_ref2)
TEST_DECLARE (pipe_ref3) TEST_DECLARE (pipe_ref3)
TEST_DECLARE (pipe_ref4) TEST_DECLARE (pipe_ref4)
TEST_DECLARE (process_ref) TEST_DECLARE (process_ref)
TEST_DECLARE (active)
TEST_DECLARE (async) TEST_DECLARE (async)
TEST_DECLARE (get_currentexe) TEST_DECLARE (get_currentexe)
TEST_DECLARE (process_title) TEST_DECLARE (process_title)
@ -328,6 +329,8 @@ TASK_LIST_START
TEST_ENTRY (loop_handles) TEST_ENTRY (loop_handles)
TEST_ENTRY (walk_handles) TEST_ENTRY (walk_handles)
TEST_ENTRY (active)
TEST_ENTRY (async) TEST_ENTRY (async)
TEST_ENTRY (get_currentexe) TEST_ENTRY (get_currentexe)

5
deps/uv/uv.gyp

@ -228,13 +228,14 @@
'test/test-get-loadavg.c', 'test/test-get-loadavg.c',
'test/task.h', 'test/task.h',
'test/test-util.c', 'test/test-util.c',
'test/test-active.c',
'test/test-async.c', 'test/test-async.c',
'test/test-error.c',
'test/test-callback-stack.c', 'test/test-callback-stack.c',
'test/test-callback-order.c', 'test/test-callback-order.c',
'test/test-connection-fail.c', 'test/test-connection-fail.c',
'test/test-cwd-and-chdir.c', 'test/test-cwd-and-chdir.c',
'test/test-delayed-accept.c', 'test/test-delayed-accept.c',
'test/test-error.c',
'test/test-fail-always.c', 'test/test-fail-always.c',
'test/test-fs.c', 'test/test-fs.c',
'test/test-fs-event.c', 'test/test-fs-event.c',
@ -343,7 +344,7 @@
'test/benchmark-spawn.c', 'test/benchmark-spawn.c',
'test/benchmark-thread.c', 'test/benchmark-thread.c',
'test/benchmark-tcp-write-batch.c', 'test/benchmark-tcp-write-batch.c',
'test/benchmark-udp-packet-storm.c', 'test/benchmark-udp-pummel.c',
'test/dns-server.c', 'test/dns-server.c',
'test/echo-server.c', 'test/echo-server.c',
'test/blackhole-server.c', 'test/blackhole-server.c',

Loading…
Cancel
Save