From 24e3cdd4d3184b8aa543bed7ce0fec6525bbbf0b Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Sat, 14 Mar 2026 20:28:03 -0400 Subject: [PATCH] fixup! fixup! fixup! fixup! win: track each write_req in a queue instead of just a count --- src/uv-common.h | 2 +- src/win/req-inl.h | 2 ++ src/win/stream.c | 2 +- src/win/tcp.c | 2 -- test/echo-server.c | 4 +--- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/uv-common.h b/src/uv-common.h index ce85880e0..6f91ba760 100644 --- a/src/uv-common.h +++ b/src/uv-common.h @@ -95,7 +95,7 @@ enum { UV_HANDLE_WRITABLE = 0x00008000, UV_HANDLE_READ_PENDING = 0x00010000, UV_HANDLE_SYNC_BYPASS_IOCP = 0x00020000, - UV_STREAM_IN_WRITE_CB = 0x00040000, + UV_HANDLE_IN_WRITE_CB = 0x00040000, UV_HANDLE_EMULATE_IOCP = 0x00080000, UV_HANDLE_BLOCKING_WRITES = 0x00100000, UV_HANDLE_CANCELLATION_PENDING = 0x00200000, diff --git a/src/win/req-inl.h b/src/win/req-inl.h index 5ed869584..686f4a195 100644 --- a/src/win/req-inl.h +++ b/src/win/req-inl.h @@ -155,7 +155,9 @@ 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/stream.c b/src/win/stream.c index 8615ed539..d043c3c97 100644 --- a/src/win/stream.c +++ b/src/win/stream.c @@ -218,7 +218,7 @@ int uv_shutdown(uv_shutdown_t* req, uv_stream_t* handle, uv_shutdown_cb cb) { handle->reqs_pending++; REGISTER_HANDLE_REQ(loop, handle); - if (!(handle->flags & UV_STREAM_IN_WRITE_CB) && + if (!(handle->flags & UV_HANDLE_IN_WRITE_CB) && uv__queue_empty(&handle->stream.conn.write_queue)) { if (handle->type == UV_NAMED_PIPE) uv__pipe_shutdown(loop, (uv_pipe_t*) handle, req); diff --git a/src/win/tcp.c b/src/win/tcp.c index c00074cf9..6072a213e 100644 --- a/src/win/tcp.c +++ b/src/win/tcp.c @@ -1103,9 +1103,7 @@ 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_STREAM_IN_WRITE_CB; req->cb(req, err); - handle->flags &= ~UV_STREAM_IN_WRITE_CB; } if (uv__queue_empty(&handle->stream.conn.write_queue)) { diff --git a/test/echo-server.c b/test/echo-server.c index 572f87df5..8fec62606 100644 --- a/test/echo-server.c +++ b/test/echo-server.c @@ -136,9 +136,7 @@ static void after_read(uv_stream_t* handle, ASSERT_NOT_NULL(wr); wr->buf = uv_buf_init(buf->base, nread); - if (uv_write(&wr->req, handle, &wr->buf, 1, after_write)) { - FATAL("uv_write failed"); - } + ASSERT_OK(uv_write(&wr->req, handle, &wr->buf, 1, after_write)); if (shutdown) ASSERT_OK(uv_shutdown(malloc(sizeof* sreq), handle, on_shutdown));