Permalink
Browse files

windows: fixes queued_bytes for ipc pipes

  • Loading branch information...
1 parent d396799 commit 773830604de102c7494b6567d2f7eac8decdb964 Igor Zinkovsky committed Oct 21, 2011
Showing with 6 additions and 4 deletions.
  1. +5 −4 src/win/pipe.c
  2. +1 −0 src/win/tcp.c
View
9 src/win/pipe.c
@@ -949,7 +949,6 @@ static int uv_pipe_write_impl(uv_loop_t* loop, uv_write_t* req,
int result;
uv_tcp_t* tcp_send_handle;
uv_write_t* ipc_header_req;
- DWORD written;
uv_ipc_frame_uv_stream ipc_frame;
if (bufcnt != 1 && (bufcnt != 0 || !send_handle)) {
@@ -1038,7 +1037,7 @@ static int uv_pipe_write_impl(uv_loop_t* loop, uv_write_t* req,
&ipc_frame,
ipc_frame.header.flags & UV_IPC_UV_STREAM ?
sizeof(ipc_frame) : sizeof(ipc_frame.header),
- &written,
+ NULL,
&ipc_header_req->overlapped);
if (!result && GetLastError() != ERROR_IO_PENDING) {
uv__set_sys_error(loop, GetLastError());
@@ -1047,10 +1046,11 @@ static int uv_pipe_write_impl(uv_loop_t* loop, uv_write_t* req,
if (result) {
/* Request completed immediately. */
- req->queued_bytes = 0;
+ ipc_header_req->queued_bytes = 0;
} else {
/* Request queued by the kernel. */
- req->queued_bytes = written;
+ ipc_header_req->queued_bytes = ipc_frame.header.flags & UV_IPC_UV_STREAM ?
+ sizeof(ipc_frame) : sizeof(ipc_frame.header);
handle->write_queue_size += req->queued_bytes;
}
@@ -1332,6 +1332,7 @@ void uv_process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle,
uv_write_t* req) {
assert(handle->type == UV_NAMED_PIPE);
+ assert(handle->write_queue_size >= req->queued_bytes);
handle->write_queue_size -= req->queued_bytes;
if (handle->flags & UV_HANDLE_EMULATE_IOCP) {
View
1 src/win/tcp.c
@@ -847,6 +847,7 @@ void uv_process_tcp_write_req(uv_loop_t* loop, uv_tcp_t* handle,
uv_write_t* req) {
assert(handle->type == UV_TCP);
+ assert(handle->write_queue_size >= req->queued_bytes);
handle->write_queue_size -= req->queued_bytes;
if (req->cb) {

0 comments on commit 7738306

Please sign in to comment.