From 7b16a3f5083ef742384e7511914764c56778da8e Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Fri, 20 Dec 2013 17:33:31 -0800 Subject: [PATCH] windows: avoid assertion failure when pipe server is closed When a pipe server is closed, all pending accept requests and their associated HANDLEs are closed to force windows to cancel the ConnectNamedPipe IRP. The returned request has the `pipeHandle` field set to INVALID_HANDLE_VALUE, which trips an assert in uv_pipe_process_accept_req. This patch fixes that. --- src/win/pipe.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/win/pipe.c b/src/win/pipe.c index fd7418d7..cce1d990 100644 --- a/src/win/pipe.c +++ b/src/win/pipe.c @@ -1480,6 +1480,13 @@ void uv_process_pipe_accept_req(uv_loop_t* loop, uv_pipe_t* handle, assert(handle->type == UV_NAMED_PIPE); + if (handle->flags & UV__HANDLE_CLOSING) { + /* The req->pipeHandle should be freed already in uv_pipe_cleanup(). */ + assert(req->pipeHandle == INVALID_HANDLE_VALUE); + DECREASE_PENDING_REQ_COUNT(handle); + return; + } + if (REQ_SUCCESS(req)) { assert(req->pipeHandle != INVALID_HANDLE_VALUE); req->next_pending = handle->pending_accepts;