windows: defer reporting TCP write failure until next tick

Fixes: https://github.com/libuv/libuv/issues/339
Reviewed-By: Bert Belder <bertbelder@gmail.com>
This commit is contained in:
Saúl Ibarra Corretgé 2015-04-30 11:15:09 +02:00
parent ee9c7bac8d
commit f880023b97

View File

@ -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;