… | |
… | |
2997 | return; |
2997 | return; |
2998 | |
2998 | |
2999 | fs_2625 = 1; |
2999 | fs_2625 = 1; |
3000 | } |
3000 | } |
3001 | |
3001 | |
|
|
3002 | inline_size int |
|
|
3003 | infy_newfd (void) |
|
|
3004 | { |
|
|
3005 | #if defined (IN_CLOEXEC) && defined (IN_NONBLOCK) |
|
|
3006 | int fd = inotify_init1 (IN_CLOEXEC | IN_NONBLOCK); |
|
|
3007 | if (fd >= 0) |
|
|
3008 | return fd; |
|
|
3009 | #endif |
|
|
3010 | return inotify_init (); |
|
|
3011 | } |
|
|
3012 | |
3002 | inline_size void |
3013 | inline_size void |
3003 | infy_init (EV_P) |
3014 | infy_init (EV_P) |
3004 | { |
3015 | { |
3005 | if (fs_fd != -2) |
3016 | if (fs_fd != -2) |
3006 | return; |
3017 | return; |
3007 | |
3018 | |
3008 | fs_fd = -1; |
3019 | fs_fd = -1; |
3009 | |
3020 | |
3010 | check_2625 (EV_A); |
3021 | check_2625 (EV_A); |
3011 | |
3022 | |
3012 | fs_fd = inotify_init (); |
3023 | fs_fd = infy_newfd (); |
3013 | |
3024 | |
3014 | if (fs_fd >= 0) |
3025 | if (fs_fd >= 0) |
3015 | { |
3026 | { |
|
|
3027 | fd_intern (fs_fd); |
3016 | ev_io_init (&fs_w, infy_cb, fs_fd, EV_READ); |
3028 | ev_io_init (&fs_w, infy_cb, fs_fd, EV_READ); |
3017 | ev_set_priority (&fs_w, EV_MAXPRI); |
3029 | ev_set_priority (&fs_w, EV_MAXPRI); |
3018 | ev_io_start (EV_A_ &fs_w); |
3030 | ev_io_start (EV_A_ &fs_w); |
3019 | } |
3031 | } |
3020 | } |
3032 | } |
… | |
… | |
3025 | int slot; |
3037 | int slot; |
3026 | |
3038 | |
3027 | if (fs_fd < 0) |
3039 | if (fs_fd < 0) |
3028 | return; |
3040 | return; |
3029 | |
3041 | |
|
|
3042 | ev_io_stop (EV_A_ &fs_w); |
3030 | close (fs_fd); |
3043 | close (fs_fd); |
3031 | fs_fd = inotify_init (); |
3044 | fs_fd = infy_newfd (); |
|
|
3045 | |
|
|
3046 | if (fs_fd >= 0) |
|
|
3047 | { |
|
|
3048 | fd_intern (fs_fd); |
|
|
3049 | ev_io_set (&fs_w, fs_fd, EV_READ); |
|
|
3050 | ev_io_start (EV_A_ &fs_w); |
|
|
3051 | } |
3032 | |
3052 | |
3033 | for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot) |
3053 | for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot) |
3034 | { |
3054 | { |
3035 | WL w_ = fs_hash [slot].head; |
3055 | WL w_ = fs_hash [slot].head; |
3036 | fs_hash [slot].head = 0; |
3056 | fs_hash [slot].head = 0; |