Skip to content

Commit

Permalink
darwin: save a fd when FSEvents is used
Browse files Browse the repository at this point in the history
Refs: #387
PR-URL: #413
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
  • Loading branch information
saghul committed Jun 30, 2015
1 parent 60fca01 commit 7980f13
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/unix/kqueue.c
Expand Up @@ -379,6 +379,10 @@ int uv_fs_event_start(uv_fs_event_t* handle,
if (!(statbuf.st_mode & S_IFDIR))
goto fallback;

/* The fallback fd is no longer needed */
uv__close(fd);
handle->event_watcher.fd = -1;

return uv__fsevents_init(handle);

fallback:
Expand Down Expand Up @@ -406,8 +410,12 @@ int uv_fs_event_stop(uv_fs_event_t* handle) {
uv__free(handle->path);
handle->path = NULL;

uv__close(handle->event_watcher.fd);
handle->event_watcher.fd = -1;
if (handle->event_watcher.fd != -1) {
/* When FSEvents is used, we don't use the event_watcher's fd under certain
* confitions. (see uv_fs_event_start) */
uv__close(handle->event_watcher.fd);
handle->event_watcher.fd = -1;
}

return 0;
}
Expand Down

0 comments on commit 7980f13

Please sign in to comment.