From 7244b9cee8d77144507af6f5d9a71f9af11df888 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 24 Nov 2011 19:57:17 +0100 Subject: [PATCH] Upgrade libuv to ea63f06 --- deps/uv/src/unix/cygwin.c | 1 + deps/uv/src/unix/fs.c | 2 +- deps/uv/src/unix/internal.h | 4 ++++ deps/uv/src/win/udp.c | 40 ++++++++++++++++++++++++++----------- deps/uv/src/win/winsock.c | 4 +++- 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/deps/uv/src/unix/cygwin.c b/deps/uv/src/unix/cygwin.c index 024e7d5bf9bc..25ff02c9f70f 100644 --- a/deps/uv/src/unix/cygwin.c +++ b/deps/uv/src/unix/cygwin.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #undef NANOSEC diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c index 57664c83c024..2ce38f14007d 100644 --- a/deps/uv/src/unix/fs.c +++ b/deps/uv/src/unix/fs.c @@ -518,11 +518,11 @@ static int _futime(const uv_file file, double atime, double mtime) { int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime, double mtime, uv_fs_cb cb) { -#if HAVE_FUTIMES const char* path = NULL; uv_fs_req_init(loop, req, UV_FS_FUTIME, path, cb); +#if HAVE_FUTIMES WRAP_EIO(UV_FS_FUTIME, eio_futime, _futime, ARGS3(file, atime, mtime)) #else uv__set_sys_error(loop, ENOSYS); diff --git a/deps/uv/src/unix/internal.h b/deps/uv/src/unix/internal.h index 12ab62177c1f..80df6a837e53 100644 --- a/deps/uv/src/unix/internal.h +++ b/deps/uv/src/unix/internal.h @@ -27,6 +27,10 @@ #include /* offsetof */ +#if __STRICT_ANSI__ +# define inline __inline +#endif + #undef HAVE_FUTIMES #undef HAVE_PIPE2 #undef HAVE_ACCEPT4 diff --git a/deps/uv/src/win/udp.c b/deps/uv/src/win/udp.c index 07082ddb5d42..3beb8ab9e631 100644 --- a/deps/uv/src/win/udp.c +++ b/deps/uv/src/win/udp.c @@ -466,17 +466,31 @@ void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, handle->flags &= ~UV_HANDLE_READ_PENDING; - if (!REQ_SUCCESS(req) && - GET_REQ_SOCK_ERROR(req) != WSAEMSGSIZE) { - /* An error occurred doing the read. */ - if (handle->flags & UV_HANDLE_READING) { - uv__set_sys_error(loop, GET_REQ_SOCK_ERROR(req)); - uv_udp_recv_stop(handle); - buf = (handle->flags & UV_HANDLE_ZERO_READ) ? - uv_buf_init(NULL, 0) : handle->recv_buffer; - handle->recv_cb(handle, -1, buf, NULL, 0); + if (!REQ_SUCCESS(req)) { + DWORD err = GET_REQ_SOCK_ERROR(req); + if (err == WSAEMSGSIZE) { + /* Not a real error, it just indicates that the received packet */ + /* was bigger than the receive buffer. */ + } else if (err == WSAECONNRESET || err == WSAENETRESET) { + /* A previous sendto operation failed; ignore this error. If */ + /* zero-reading we need to call WSARecv/WSARecvFrom _without_ the */ + /* MSG_PEEK flag to clear out the error queue. For nonzero reads, */ + /* immediately queue a new receive. */ + if (!(handle->flags & UV_HANDLE_ZERO_READ)) { + goto done; + } + } else { + /* A real error occurred. Report the error to the user only if we're */ + /* currently reading. */ + if (handle->flags & UV_HANDLE_READING) { + uv__set_sys_error(loop, err); + uv_udp_recv_stop(handle); + buf = (handle->flags & UV_HANDLE_ZERO_READ) ? + uv_buf_init(NULL, 0) : handle->recv_buffer; + handle->recv_cb(handle, -1, buf, NULL, 0); + } + goto done; } - goto done; } if (!(handle->flags & UV_HANDLE_ZERO_READ)) { @@ -527,8 +541,10 @@ void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle, /* Kernel buffer empty */ uv__set_sys_error(loop, WSAEWOULDBLOCK); handle->recv_cb(handle, 0, buf, NULL, 0); - } else { - /* Ouch! serious error. */ + } else if (err != WSAECONNRESET && err != WSAENETRESET) { + /* Serious error. WSAECONNRESET/WSANETRESET is ignored because this */ + /* just indicates that a previous sendto operation failed. */ + uv_udp_recv_stop(handle); uv__set_sys_error(loop, err); handle->recv_cb(handle, -1, buf, NULL, 0); } diff --git a/deps/uv/src/win/winsock.c b/deps/uv/src/win/winsock.c index 5309f1eedb17..78acba9091cb 100644 --- a/deps/uv/src/win/winsock.c +++ b/deps/uv/src/win/winsock.c @@ -144,6 +144,7 @@ int uv_ntstatus_to_winsock_error(NTSTATUS status) { case STATUS_LINK_FAILED: case STATUS_CONNECTION_DISCONNECTED: case STATUS_PORT_UNREACHABLE: + case STATUS_HOPLIMIT_EXCEEDED: return WSAECONNRESET; case STATUS_LOCAL_DISCONNECT: @@ -206,7 +207,8 @@ int uv_ntstatus_to_winsock_error(NTSTATUS status) { return WSAEACCES; default: - if (status & ((FACILITY_NTWIN32 << 16) | ERROR_SEVERITY_ERROR)) { + if ((status & (FACILITY_NTWIN32 << 16)) == (FACILITY_NTWIN32 << 16) && + (status & (ERROR_SEVERITY_ERROR | ERROR_SEVERITY_WARNING))) { /* It's a windows error that has been previously mapped to an */ /* ntstatus code. */ return (DWORD) (status & 0xffff);