Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: move inotify init logic to loop.c
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Apr 5, 2012
1 parent 68bed69 commit f4e7537
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
10 changes: 0 additions & 10 deletions src/unix/internal.h
Expand Up @@ -157,14 +157,4 @@ void uv__udp_close(uv_udp_t* handle);
int uv__make_socketpair(int fds[2], int flags);
int uv__make_pipe(int fds[2], int flags);

#if __linux__
void uv__inotify_loop_init(uv_loop_t* loop);
void uv__inotify_loop_delete(uv_loop_t* loop);
# define uv__loop_platform_init(loop) uv__inotify_loop_init(loop)
# define uv__loop_platform_delete(loop) uv__inotify_loop_delete(loop)
#else
# define uv__loop_platform_init(loop)
# define uv__loop_platform_delete(loop)
#endif

#endif /* UV_UNIX_INTERNAL_H_ */
14 changes: 0 additions & 14 deletions src/unix/linux/inotify.c
Expand Up @@ -51,20 +51,6 @@ static int compare_watchers(const uv_fs_event_t* a, const uv_fs_event_t* b) {
RB_GENERATE_STATIC(uv__inotify_watchers, uv_fs_event_s, node, compare_watchers)


void uv__inotify_loop_init(uv_loop_t* loop) {
RB_INIT(&loop->inotify_watchers);
loop->inotify_fd = -1;
}


void uv__inotify_loop_delete(uv_loop_t* loop) {
if (loop->inotify_fd == -1) return;
ev_io_stop(loop->ev, &loop->inotify_read_watcher);
close(loop->inotify_fd);
loop->inotify_fd = -1;
}


static void uv__inotify_read(EV_P_ ev_io* w, int revents);


Expand Down
12 changes: 10 additions & 2 deletions src/unix/loop.c
Expand Up @@ -37,13 +37,21 @@ int uv__loop_init(uv_loop_t* loop, int default_loop) {
loop->ev = (default_loop ? ev_default_loop : ev_loop_new)(flags);
ev_set_userdata(loop->ev, loop);
eio_channel_init(&loop->uv_eio_channel, loop);
uv__loop_platform_init(loop);
#if __linux__
RB_INIT(&loop->inotify_watchers);
loop->inotify_fd = -1;
#endif
return 0;
}


void uv__loop_delete(uv_loop_t* loop) {
uv_ares_destroy(loop, loop->channel);
ev_loop_destroy(loop->ev);
uv__loop_platform_delete(loop);
#if __linux__
if (loop->inotify_fd == -1) return;
ev_io_stop(loop->ev, &loop->inotify_read_watcher);
close(loop->inotify_fd);
loop->inotify_fd = -1;
#endif
}

0 comments on commit f4e7537

Please sign in to comment.