… | |
… | |
47 | # include EV_CONFIG_H |
47 | # include EV_CONFIG_H |
48 | # else |
48 | # else |
49 | # include "config.h" |
49 | # include "config.h" |
50 | # endif |
50 | # endif |
51 | |
51 | |
|
|
52 | # if HAVE_CLOCK_SYSCALL |
|
|
53 | # ifndef EV_USE_CLOCK_SYSCALL |
|
|
54 | # define EV_USE_CLOCK_SYSCALL 1 |
|
|
55 | # ifndef EV_USE_REALTIME |
|
|
56 | # define EV_USE_REALTIME 0 |
|
|
57 | # endif |
|
|
58 | # ifndef EV_USE_MONOTONIC |
|
|
59 | # define EV_USE_MONOTONIC 1 |
|
|
60 | # endif |
|
|
61 | # endif |
|
|
62 | # endif |
|
|
63 | |
52 | # if HAVE_CLOCK_GETTIME |
64 | # if HAVE_CLOCK_GETTIME |
53 | # ifndef EV_USE_MONOTONIC |
65 | # ifndef EV_USE_MONOTONIC |
54 | # define EV_USE_MONOTONIC 1 |
66 | # define EV_USE_MONOTONIC 1 |
55 | # endif |
67 | # endif |
56 | # ifndef EV_USE_REALTIME |
68 | # ifndef EV_USE_REALTIME |
… | |
… | |
164 | # endif |
176 | # endif |
165 | #endif |
177 | #endif |
166 | |
178 | |
167 | /* this block tries to deduce configuration from header-defined symbols and defaults */ |
179 | /* this block tries to deduce configuration from header-defined symbols and defaults */ |
168 | |
180 | |
|
|
181 | #ifndef EV_USE_CLOCK_SYSCALL |
|
|
182 | # if __linux && __GLIBC__ >= 2 |
|
|
183 | # define EV_USE_CLOCK_SYSCALL 1 |
|
|
184 | # else |
|
|
185 | # define EV_USE_CLOCK_SYSCALL 0 |
|
|
186 | # endif |
|
|
187 | #endif |
|
|
188 | |
169 | #ifndef EV_USE_MONOTONIC |
189 | #ifndef EV_USE_MONOTONIC |
170 | # if defined (_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 |
190 | # if defined (_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 |
171 | # define EV_USE_MONOTONIC 1 |
191 | # define EV_USE_MONOTONIC 1 |
172 | # else |
192 | # else |
173 | # define EV_USE_MONOTONIC 0 |
193 | # define EV_USE_MONOTONIC 0 |
… | |
… | |
298 | # endif |
318 | # endif |
299 | #endif |
319 | #endif |
300 | |
320 | |
301 | #if EV_SELECT_IS_WINSOCKET |
321 | #if EV_SELECT_IS_WINSOCKET |
302 | # include <winsock.h> |
322 | # include <winsock.h> |
|
|
323 | #endif |
|
|
324 | |
|
|
325 | /* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */ |
|
|
326 | /* which makes programs even slower. might work on other unices, too. */ |
|
|
327 | #if EV_USE_CLOCK_SYSCALL |
|
|
328 | # include <syscall.h> |
|
|
329 | # define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts)) |
|
|
330 | # undef EV_USE_MONOTONIC |
|
|
331 | # define EV_USE_MONOTONIC 1 |
303 | #endif |
332 | #endif |
304 | |
333 | |
305 | #if EV_USE_EVENTFD |
334 | #if EV_USE_EVENTFD |
306 | /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ |
335 | /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ |
307 | # include <stdint.h> |
336 | # include <stdint.h> |
… | |
… | |
1241 | /* kqueue is borked on everything but netbsd apparently */ |
1270 | /* kqueue is borked on everything but netbsd apparently */ |
1242 | /* it usually doesn't work correctly on anything but sockets and pipes */ |
1271 | /* it usually doesn't work correctly on anything but sockets and pipes */ |
1243 | flags &= ~EVBACKEND_KQUEUE; |
1272 | flags &= ~EVBACKEND_KQUEUE; |
1244 | #endif |
1273 | #endif |
1245 | #ifdef __APPLE__ |
1274 | #ifdef __APPLE__ |
1246 | // flags &= ~EVBACKEND_KQUEUE; for documentation |
1275 | // flags &= ~EVBACKEND_KQUEUE & ~EVBACKEND_POLL; for documentation |
1247 | flags &= ~EVBACKEND_POLL; |
1276 | flags &= ~EVBACKEND_SELECT; |
1248 | #endif |
1277 | #endif |
1249 | |
1278 | |
1250 | return flags; |
1279 | return flags; |
1251 | } |
1280 | } |
1252 | |
1281 | |
… | |
… | |
2449 | int mask = IN_MASK_ADD | IN_DELETE_SELF | IN_MOVE_SELF |
2478 | int mask = IN_MASK_ADD | IN_DELETE_SELF | IN_MOVE_SELF |
2450 | | (errno == EACCES ? IN_ATTRIB : IN_CREATE | IN_MOVED_TO); |
2479 | | (errno == EACCES ? IN_ATTRIB : IN_CREATE | IN_MOVED_TO); |
2451 | |
2480 | |
2452 | char *pend = strrchr (path, '/'); |
2481 | char *pend = strrchr (path, '/'); |
2453 | |
2482 | |
2454 | if (!pend) |
2483 | if (!pend || pend == path) |
2455 | break; /* whoops, no '/', complain to your admin */ |
2484 | break; |
2456 | |
2485 | |
2457 | *pend = 0; |
2486 | *pend = 0; |
2458 | w->wd = inotify_add_watch (fs_fd, path, mask); |
2487 | w->wd = inotify_add_watch (fs_fd, path, mask); |
2459 | } |
2488 | } |
2460 | while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); |
2489 | while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); |
2461 | } |
2490 | } |
2462 | } |
2491 | } |
2463 | else |
2492 | |
|
|
2493 | if (w->wd >= 0) |
2464 | { |
2494 | { |
2465 | wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); |
2495 | wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); |
2466 | |
2496 | |
2467 | /* now local changes will be tracked by inotify, but remote changes won't */ |
2497 | /* now local changes will be tracked by inotify, but remote changes won't */ |
2468 | /* unless the filesystem it known to be local, we therefore still poll */ |
2498 | /* unless the filesystem it known to be local, we therefore still poll */ |
… | |
… | |
2518 | |
2548 | |
2519 | if (w->wd == wd || wd == -1) |
2549 | if (w->wd == wd || wd == -1) |
2520 | { |
2550 | { |
2521 | if (ev->mask & (IN_IGNORED | IN_UNMOUNT | IN_DELETE_SELF)) |
2551 | if (ev->mask & (IN_IGNORED | IN_UNMOUNT | IN_DELETE_SELF)) |
2522 | { |
2552 | { |
|
|
2553 | wlist_del (&fs_hash [slot & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); |
2523 | w->wd = -1; |
2554 | w->wd = -1; |
2524 | infy_add (EV_A_ w); /* re-add, no matter what */ |
2555 | infy_add (EV_A_ w); /* re-add, no matter what */ |
2525 | } |
2556 | } |
2526 | |
2557 | |
2527 | stat_timer_cb (EV_A_ &w->timer, 0); |
2558 | stat_timer_cb (EV_A_ &w->timer, 0); |