From 63c9c35f6b5147c59e6b7e241c421b982e5d1e67 Mon Sep 17 00:00:00 2001 From: James Hartig Date: Thu, 22 Dec 2011 17:55:49 -0500 Subject: [PATCH] Libuv updated --- deps/uv/LICENSE | 2 ++ deps/uv/include/uv.h | 4 +++- deps/uv/src/unix/internal.h | 2 +- deps/uv/src/unix/stream.c | 2 +- deps/uv/src/unix/tcp.c | 29 ++++++++++++++++++++++++++--- deps/uv/src/win/tcp.c | 14 ++++++++++---- deps/uv/test/test-tcp-flags.c | 2 +- 7 files changed, 44 insertions(+), 11 deletions(-) diff --git a/deps/uv/LICENSE b/deps/uv/LICENSE index f7df47f71c9..f62d7f1991c 100644 --- a/deps/uv/LICENSE +++ b/deps/uv/LICENSE @@ -33,6 +33,8 @@ The externally maintained libraries used by libuv are: - ngx_queue.h (from Nginx), copyright Igor Sysoev. Two clause BSD license. + - c-ares, copyright Daniel Stenberg and others. MIT licensed. + - libev, located at ev/ is copyright Marc Alexander Lehmann, and dual-licensed under the MIT license and GPL2. diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h index a2007087550..2d7180246aa 100644 --- a/deps/uv/include/uv.h +++ b/deps/uv/include/uv.h @@ -483,9 +483,11 @@ UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable); /* Enable/disable TCP keep-alive. * * `ms` is the initial delay in seconds, ignored when `enable` is zero. + * interval is the keep-alive probe interval after the initial delay. Doesn't work in Windows + * count is the number of keep-alives that fail before thinking the socket is dead. Doesn't work in Windows */ UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, int enable, - unsigned int delay); + unsigned int delay, unsigned int interval, unsigned int count); /* * This setting applies to Windows only. diff --git a/deps/uv/src/unix/internal.h b/deps/uv/src/unix/internal.h index 1adb5f2054d..4a7a936627b 100644 --- a/deps/uv/src/unix/internal.h +++ b/deps/uv/src/unix/internal.h @@ -173,7 +173,7 @@ int uv__connect(uv_connect_t* req, uv_stream_t* stream, struct sockaddr* addr, /* tcp */ int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb); int uv__tcp_nodelay(uv_tcp_t* handle, int enable); -int uv__tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay); +int uv__tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay, unsigned int interval, unsigned int count); /* pipe */ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb); diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c index e0689fbcdcd..c7d8330cb1d 100644 --- a/deps/uv/src/unix/stream.c +++ b/deps/uv/src/unix/stream.c @@ -102,7 +102,7 @@ int uv__stream_open(uv_stream_t* stream, int fd, int flags) { /* TODO Use delay the user passed in. */ if ((stream->flags & UV_TCP_KEEPALIVE) && - uv__tcp_keepalive((uv_tcp_t*)stream, 1, 60)) { + uv__tcp_keepalive((uv_tcp_t*)stream, 1, 60, 60, 8)) { return -1; } } diff --git a/deps/uv/src/unix/tcp.c b/deps/uv/src/unix/tcp.c index ee94ab3ed84..fec626973a0 100644 --- a/deps/uv/src/unix/tcp.c +++ b/deps/uv/src/unix/tcp.c @@ -255,7 +255,8 @@ int uv__tcp_nodelay(uv_tcp_t* handle, int enable) { } -int uv__tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) { +int uv__tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay, + unsigned int interval, unsigned int count) { if (setsockopt(handle->fd, SOL_SOCKET, SO_KEEPALIVE, @@ -287,6 +288,28 @@ int uv__tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) { } #endif +#ifdef TCP_KEEPINTVL + if (enable && interval && setsockopt(handle->fd, + IPPROTO_TCP, + TCP_KEEPINTVL, + &interval, + sizeof interval) == -1) { + uv__set_sys_error(handle->loop, errno); + return -1; + } +#endif + +#ifdef TCP_KEEPCNT + if (enable && count && setsockopt(handle->fd, + IPPROTO_TCP, + TCP_KEEPCNT, + &count, + sizeof count) == -1) { + uv__set_sys_error(handle->loop, errno); + return -1; + } +#endif + return 0; } @@ -304,8 +327,8 @@ int uv_tcp_nodelay(uv_tcp_t* handle, int enable) { } -int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) { - if (handle->fd != -1 && uv__tcp_keepalive(handle, enable, delay)) +int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay, unsigned int interval, unsigned int count) { + if (handle->fd != -1 && uv__tcp_keepalive(handle, enable, delay, interval, count)) return -1; if (enable) diff --git a/deps/uv/src/win/tcp.c b/deps/uv/src/win/tcp.c index 7965f73aa46..a75188c395e 100644 --- a/deps/uv/src/win/tcp.c +++ b/deps/uv/src/win/tcp.c @@ -59,7 +59,8 @@ static int uv__tcp_nodelay(uv_tcp_t* handle, SOCKET socket, int enable) { } -static int uv__tcp_keepalive(uv_tcp_t* handle, SOCKET socket, int enable, unsigned int delay) { +static int uv__tcp_keepalive(uv_tcp_t* handle, SOCKET socket, int enable, unsigned int delay, + unsigned int interval, unsigned int count) { if (setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, @@ -78,6 +79,11 @@ static int uv__tcp_keepalive(uv_tcp_t* handle, SOCKET socket, int enable, unsign return -1; } + /* + * interval and count cannot be applied without registry + * changes and system reboot + */ + return 0; } @@ -132,7 +138,7 @@ static int uv_tcp_set_socket(uv_loop_t* loop, uv_tcp_t* handle, /* TODO: Use stored delay. */ if ((handle->flags & UV_HANDLE_TCP_KEEPALIVE) && - uv__tcp_keepalive(handle, socket, 1, 60)) { + uv__tcp_keepalive(handle, socket, 1, 60, 60, 8)) { return -1; } @@ -1059,9 +1065,9 @@ int uv_tcp_nodelay(uv_tcp_t* handle, int enable) { } -int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) { +int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay, unsigned int interval, unsigned int count) { if (handle->socket != INVALID_SOCKET && - uv__tcp_keepalive(handle, handle->socket, enable, delay)) { + uv__tcp_keepalive(handle, handle->socket, enable, delay, interval, count)) { return -1; } diff --git a/deps/uv/test/test-tcp-flags.c b/deps/uv/test/test-tcp-flags.c index c441b563f4a..79c5fbc094f 100644 --- a/deps/uv/test/test-tcp-flags.c +++ b/deps/uv/test/test-tcp-flags.c @@ -39,7 +39,7 @@ TEST_IMPL(tcp_flags) { r = uv_tcp_nodelay(&handle, 1); ASSERT(r == 0); - r = uv_tcp_keepalive(&handle, 1, 60); + r = uv_tcp_keepalive(&handle, 1, 60, 60, 8); ASSERT(r == 0); uv_close((uv_handle_t*)&handle, NULL);