Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

unix: properly disarm kqueue fs watcher

Fixes "Assertion failed: (revents == EV_LIBUV_KQUEUE_HACK),
function uv__fs_event, file ../src/unix/kqueue.c, line 58."
  • Loading branch information...
commit 1e0aab06c92838b427ecf41ead62d1e5fcc8e4c5 1 parent b0b54bf
@bnoordhuis bnoordhuis authored
Showing with 44 additions and 1 deletion.
  1. +1 −0  src/unix/kqueue.c
  2. +41 −1 test/test-fs-event.c
  3. +2 −0  test/test-list.h
View
1  src/unix/kqueue.c
@@ -116,6 +116,7 @@ int uv_fs_event_init(uv_loop_t* loop,
void uv__fs_event_destroy(uv_fs_event_t* handle) {
+ uv__fs_event_stop(handle);
free(handle->filename);
uv__close(handle->fd);
handle->fd = -1;
View
42 test/test-fs-event.c
@@ -267,4 +267,44 @@ TEST_IMPL(fs_event_no_callback_on_close) {
r = uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL);
return 0;
-}
+}
+
+
+static void fs_event_fail(uv_fs_event_t* handle, const char* filename,
+ int events, int status) {
+ ASSERT(0 && "should never be called");
+}
+
+
+static void timer_cb(uv_timer_t* handle, int status) {
+ int r;
+
+ ASSERT(status == 0);
+
+ r = uv_fs_event_init(handle->loop, &fs_event, ".", fs_event_fail, 0);
+ ASSERT(r != -1);
+
+ uv_close((uv_handle_t*)&fs_event, close_cb);
+ uv_close((uv_handle_t*)handle, close_cb);
+}
+
+
+TEST_IMPL(fs_event_immediate_close) {
+ uv_timer_t timer;
+ uv_loop_t* loop;
+ int r;
+
+ loop = uv_default_loop();
+
+ r = uv_timer_init(loop, &timer);
+ ASSERT(r == 0);
+
+ r = uv_timer_start(&timer, timer_cb, 1, 0);
+ ASSERT(r == 0);
+
+ uv_run(loop);
+
+ ASSERT(close_cb_called == 2);
+
+ return 0;
+}
View
2  test/test-list.h
@@ -110,6 +110,7 @@ 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_event_immediate_close)
TEST_DECLARE (fs_readdir_empty_dir)
TEST_DECLARE (fs_readdir_file)
TEST_DECLARE (fs_open_dir)
@@ -261,6 +262,7 @@ TASK_LIST_START
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_event_immediate_close)
TEST_ENTRY (fs_readdir_empty_dir)
TEST_ENTRY (fs_readdir_file)
TEST_ENTRY (fs_open_dir)
Please sign in to comment.
Something went wrong with that request. Please try again.