From 2c0fca9a4137ffac080654bf64f528ee2b4e6bbc Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Tue, 27 Sep 2011 19:11:42 +0200 Subject: [PATCH] win: Fix crash when calling uv_close from shutdown callback --- src/win/pipe.c | 1 + src/win/tcp.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/win/pipe.c b/src/win/pipe.c index 9865e3a8..8d789153 100644 --- a/src/win/pipe.c +++ b/src/win/pipe.c @@ -231,6 +231,7 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) { if (result) { /* Mark the handle as shut now to avoid going through this again. */ handle->flags |= UV_HANDLE_SHUT; + return; } else { /* Failure. */ diff --git a/src/win/tcp.c b/src/win/tcp.c index ebd83534..783d5fb9 100644 --- a/src/win/tcp.c +++ b/src/win/tcp.c @@ -128,7 +128,9 @@ void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle) { } handle->shutdown_req->cb(handle->shutdown_req, status); } - handle->reqs_pending--; + + DECREASE_PENDING_REQ_COUNT(handle); + return; } if (handle->flags & UV_HANDLE_CLOSING &&