diff --git a/src/win/pipe.c b/src/win/pipe.c index 624f5346c..1a3bc5dc1 100644 --- a/src/win/pipe.c +++ b/src/win/pipe.c @@ -2166,7 +2166,9 @@ void uv__process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle, uv__free(coalesced_write); } if (req->cb) { + handle->flags |= UV_HANDLE_IN_WRITE_CB; req->cb(req, uv_translate_sys_error(err)); + handle->flags &= ~UV_HANDLE_IN_WRITE_CB; } if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE && diff --git a/src/win/req-inl.h b/src/win/req-inl.h index 686f4a195..5ed869584 100644 --- a/src/win/req-inl.h +++ b/src/win/req-inl.h @@ -155,9 +155,7 @@ INLINE static void uv__process_reqs(uv_loop_t* loop) { break; case UV_WRITE: - ((uv_write_t*) req)->handle->flags |= UV_HANDLE_IN_WRITE_CB; DELEGATE_STREAM_REQ(loop, (uv_write_t*) req, write, handle); - ((uv_write_t*) req)->handle->flags &= ~UV_HANDLE_IN_WRITE_CB; break; case UV_ACCEPT: diff --git a/src/win/tcp.c b/src/win/tcp.c index 6072a213e..8d7d9b471 100644 --- a/src/win/tcp.c +++ b/src/win/tcp.c @@ -1103,7 +1103,9 @@ void uv__process_tcp_write_req(uv_loop_t* loop, uv_tcp_t* handle, /* use UV_ECANCELED for consistency with Unix */ err = UV_ECANCELED; } + handle->flags |= UV_HANDLE_IN_WRITE_CB; req->cb(req, err); + handle->flags &= ~UV_HANDLE_IN_WRITE_CB; } if (uv__queue_empty(&handle->stream.conn.write_queue)) { diff --git a/src/win/tty.c b/src/win/tty.c index 6c29071fe..6da2090a7 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -2208,7 +2208,9 @@ void uv__process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle, if (req->cb) { err = GET_REQ_ERROR(req); + handle->flags |= UV_HANDLE_IN_WRITE_CB; req->cb(req, uv_translate_sys_error(err)); + handle->flags &= ~UV_HANDLE_IN_WRITE_CB; }