Skip to content

Instantly share code, notes, and snippets.

@piscisaureus
Created September 16, 2011 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piscisaureus/3f5b4b1c654ebb21ce55 to your computer and use it in GitHub Desktop.
Save piscisaureus/3f5b4b1c654ebb21ce55 to your computer and use it in GitHub Desktop.
diff --git a/src/win/tcp.c b/src/win/tcp.c
index ebd8353..10428b5 100644
--- a/src/win/tcp.c
+++ b/src/win/tcp.c
@@ -659,7 +659,12 @@ int uv_tcp_write(uv_loop_t* loop, uv_write_t* req, uv_tcp_t* handle,
req->queued_bytes = 0;
handle->reqs_pending++;
handle->write_reqs_pending++;
- uv_insert_pending_req(loop, (uv_req_t*) req);
+
+ if (handle->write_reqs_pending == 1) {
+ uv_insert_pending_req(loop, (uv_req_t*) req);
+ } else {
+ POST_COMPLETION_FOR_REQ(loop, (uv_req_t*) req);
+ }
} else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) {
/* Request queued by the kernel. */
req->queued_bytes = uv_count_bufs(bufs, bufcnt);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment