From f880023b97b5eb79ea44917bc0c90039dca02395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 30 Apr 2015 11:15:09 +0200 Subject: [PATCH] windows: defer reporting TCP write failure until next tick Fixes: https://github.com/libuv/libuv/issues/339 Reviewed-By: Bert Belder --- src/win/tcp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/win/tcp.c b/src/win/tcp.c index 645a3e09..8b0e18c7 100644 --- a/src/win/tcp.c +++ b/src/win/tcp.c @@ -868,8 +868,13 @@ int uv_tcp_write(uv_loop_t* loop, uv_insert_pending_req(loop, (uv_req_t*)req); } } else { - /* Send failed due to an error. */ - return WSAGetLastError(); + /* Send failed due to an error, report it later */ + req->u.io.queued_bytes = 0; + handle->reqs_pending++; + handle->stream.conn.write_reqs_pending++; + REGISTER_HANDLE_REQ(loop, handle, req); + SET_REQ_ERROR(req, WSAGetLastError()); + uv_insert_pending_req(loop, (uv_req_t*) req); } return 0;