From 1795427ab0d885cae3aa9bbcecb423c4bf863749 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Tue, 27 Mar 2012 22:53:30 +0200 Subject: [PATCH] Windows: never call fs event callbacks after closing the watcher --- src/win/fs-event.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/win/fs-event.c b/src/win/fs-event.c index 5a25e9d6..3b37c752 100644 --- a/src/win/fs-event.c +++ b/src/win/fs-event.c @@ -301,6 +301,13 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, assert(handle->req_pending); handle->req_pending = 0; + /* If we're closing, don't report any callbacks, and just push the handle */ + /* onto the endgame queue. */ + if (handle->flags & UV_HANDLE_CLOSING) { + uv_want_endgame(loop, (uv_handle_t*) handle); + return; + }; + file_info = (FILE_NOTIFY_INFORMATION*)(handle->buffer + offset); if (REQ_SUCCESS(req)) { @@ -438,11 +445,9 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, } offset = file_info->NextEntryOffset; - } while(offset); + } while (offset && !(handle->flags & UV_HANDLE_CLOSING)); } else { - if (!(handle->flags & UV_HANDLE_CLOSING)) { - handle->cb(handle, NULL, UV_CHANGE, 0); - } + handle->cb(handle, NULL, UV_CHANGE, 0); } } else { uv__set_sys_error(loop, GET_REQ_ERROR(req));