Created
November 24, 2011 14:13
-
-
Save piscisaureus/1391433 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 00ec9f8ae916758293f63200b5def7a4487e85b5 Mon Sep 17 00:00:00 2001 | |
From: Bert Belder <bertbelder@gmail.com> | |
Date: Thu, 24 Nov 2011 15:10:23 +0100 | |
Subject: [PATCH 1/1] Windows: ignore ECONNRESET that happen while receiving | |
udp packets | |
--- | |
deps/uv/src/win/udp.c | 36 ++++++++++++++++++++++++------------ | |
1 files changed, 24 insertions(+), 12 deletions(-) | |
diff --git a/deps/uv/src/win/udp.c b/deps/uv/src/win/udp.c | |
index 07082dd..d6e1d53 100644 | |
--- a/deps/uv/src/win/udp.c | |
+++ b/deps/uv/src/win/udp.c | |
@@ -466,17 +466,27 @@ 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) { | |
+ /* A previous sendto operation failed. Ignore this error and */ | |
+ /* queue a new recv request. */ | |
+ 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 +537,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) { | |
+ /* Serious error. WSAECONNRESET is ignore 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); | |
} | |
-- | |
1.7.7.1.msysgit.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment