windows: don't emit fs-event callback after uv_fs_event handle is closed

This commit is contained in:
Igor Zinkovsky 2011-11-02 19:09:18 -07:00
parent 77a2477c3f
commit 0fb3769586
3 changed files with 34 additions and 1 deletions

View File

@ -353,7 +353,9 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
offset = file_info->NextEntryOffset;
} while(offset);
} else {
handle->cb(handle, NULL, UV_CHANGE, 0);
if (!(handle->flags & UV_HANDLE_CLOSING)) {
handle->cb(handle, NULL, UV_CHANGE, 0);
}
}
} else {
uv__set_sys_error(loop, GET_REQ_ERROR(req));

View File

@ -235,3 +235,32 @@ TEST_IMPL(fs_event_watch_file_current_dir) {
r = uv_fs_unlink(loop, &fs_req, "watch_file", NULL);
return 0;
}
TEST_IMPL(fs_event_no_callback_on_close) {
uv_fs_t fs_req;
uv_loop_t* loop = uv_default_loop();
int r;
/* Setup */
uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL);
uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL);
create_dir(loop, "watch_dir");
create_file(loop, "watch_dir/file1");
r = uv_fs_event_init(loop, &fs_event, "watch_dir/file1", fs_event_cb_file);
ASSERT(r != -1);
uv_close((uv_handle_t*)&fs_event, close_cb);
uv_run(loop);
ASSERT(fs_event_cb_called == 0);
ASSERT(close_cb_called == 1);
/* Cleanup */
r = uv_fs_unlink(loop, &fs_req, "watch_dir/file1", NULL);
r = uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL);
return 0;
}

View File

@ -106,6 +106,7 @@ TEST_DECLARE (fs_stat_missing_path)
TEST_DECLARE (fs_event_watch_dir)
TEST_DECLARE (fs_event_watch_file)
TEST_DECLARE (fs_event_watch_file_current_dir)
TEST_DECLARE (fs_event_no_callback_on_close)
TEST_DECLARE (fs_readdir_empty_dir)
TEST_DECLARE (fs_readdir_file)
TEST_DECLARE (fs_open_dir)
@ -252,6 +253,7 @@ TASK_LIST_START
TEST_ENTRY (fs_event_watch_dir)
TEST_ENTRY (fs_event_watch_file)
TEST_ENTRY (fs_event_watch_file_current_dir)
TEST_ENTRY (fs_event_no_callback_on_close)
TEST_ENTRY (fs_readdir_empty_dir)
TEST_ENTRY (fs_readdir_file)
TEST_ENTRY (fs_open_dir)