Skip to content

Instantly share code, notes, and snippets.

@saghul
Created April 30, 2015 09:15
Show Gist options
  • Save saghul/e05b99b1b16a7c9c15e9 to your computer and use it in GitHub Desktop.
Save saghul/e05b99b1b16a7c9c15e9 to your computer and use it in GitHub Desktop.
commit ad54c691cf50d0ac396dffccc714699c2b0f3ef0
Author: Saúl Ibarra Corretgé <saghul@gmail.com>
Date: Thu Apr 30 11:15:09 2015 +0200
windows: defer reporting TCP write failure until next tick
diff --git a/src/win/tcp.c b/src/win/tcp.c
index 645a3e0..8b0e18c 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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment