… | |
… | |
287 | # endif |
287 | # endif |
288 | #endif |
288 | #endif |
289 | |
289 | |
290 | #if EV_USE_INOTIFY |
290 | #if EV_USE_INOTIFY |
291 | # include <sys/utsname.h> |
291 | # include <sys/utsname.h> |
|
|
292 | # include <sys/statfs.h> |
292 | # include <sys/inotify.h> |
293 | # include <sys/inotify.h> |
293 | /* some very old inotify.h headers don't have IN_DONT_FOLLOW */ |
294 | /* some very old inotify.h headers don't have IN_DONT_FOLLOW */ |
294 | # ifndef IN_DONT_FOLLOW |
295 | # ifndef IN_DONT_FOLLOW |
295 | # undef EV_USE_INOTIFY |
296 | # undef EV_USE_INOTIFY |
296 | # define EV_USE_INOTIFY 0 |
297 | # define EV_USE_INOTIFY 0 |
… | |
… | |
388 | { |
389 | { |
389 | syserr_cb = cb; |
390 | syserr_cb = cb; |
390 | } |
391 | } |
391 | |
392 | |
392 | static void noinline |
393 | static void noinline |
393 | syserr (const char *msg) |
394 | ev_syserr (const char *msg) |
394 | { |
395 | { |
395 | if (!msg) |
396 | if (!msg) |
396 | msg = "(libev) system error"; |
397 | msg = "(libev) system error"; |
397 | |
398 | |
398 | if (syserr_cb) |
399 | if (syserr_cb) |
… | |
… | |
450 | { |
451 | { |
451 | WL head; |
452 | WL head; |
452 | unsigned char events; |
453 | unsigned char events; |
453 | unsigned char reify; |
454 | unsigned char reify; |
454 | unsigned char emask; /* the epoll backend stores the actual kernel mask in here */ |
455 | unsigned char emask; /* the epoll backend stores the actual kernel mask in here */ |
|
|
456 | unsigned char unused; |
|
|
457 | #if EV_USE_EPOLL |
455 | unsigned char egen; /* generation counter to counter epoll bugs */ |
458 | unsigned int egen; /* generation counter to counter epoll bugs */ |
|
|
459 | #endif |
456 | #if EV_SELECT_IS_WINSOCKET |
460 | #if EV_SELECT_IS_WINSOCKET |
457 | SOCKET handle; |
461 | SOCKET handle; |
458 | #endif |
462 | #endif |
459 | } ANFD; |
463 | } ANFD; |
460 | |
464 | |
… | |
… | |
806 | |
810 | |
807 | for (fd = 0; fd < anfdmax; ++fd) |
811 | for (fd = 0; fd < anfdmax; ++fd) |
808 | if (anfds [fd].events) |
812 | if (anfds [fd].events) |
809 | { |
813 | { |
810 | anfds [fd].events = 0; |
814 | anfds [fd].events = 0; |
|
|
815 | anfds [fd].emask = 0; |
811 | fd_change (EV_A_ fd, EV_IOFDSET | 1); |
816 | fd_change (EV_A_ fd, EV_IOFDSET | 1); |
812 | } |
817 | } |
813 | } |
818 | } |
814 | |
819 | |
815 | /*****************************************************************************/ |
820 | /*****************************************************************************/ |
… | |
… | |
997 | } |
1002 | } |
998 | else |
1003 | else |
999 | #endif |
1004 | #endif |
1000 | { |
1005 | { |
1001 | while (pipe (evpipe)) |
1006 | while (pipe (evpipe)) |
1002 | syserr ("(libev) error creating signal/async pipe"); |
1007 | ev_syserr ("(libev) error creating signal/async pipe"); |
1003 | |
1008 | |
1004 | fd_intern (evpipe [0]); |
1009 | fd_intern (evpipe [0]); |
1005 | fd_intern (evpipe [1]); |
1010 | fd_intern (evpipe [1]); |
1006 | ev_io_set (&pipeev, evpipe [0], EV_READ); |
1011 | ev_io_set (&pipeev, evpipe [0], EV_READ); |
1007 | } |
1012 | } |
… | |
… | |
1655 | { |
1660 | { |
1656 | #if EV_MULTIPLICITY |
1661 | #if EV_MULTIPLICITY |
1657 | struct ev_loop *loop = ev_default_loop_ptr; |
1662 | struct ev_loop *loop = ev_default_loop_ptr; |
1658 | #endif |
1663 | #endif |
1659 | |
1664 | |
1660 | if (backend) |
|
|
1661 | postfork = 1; /* must be in line with ev_loop_fork */ |
1665 | postfork = 1; /* must be in line with ev_loop_fork */ |
1662 | } |
1666 | } |
1663 | |
1667 | |
1664 | /*****************************************************************************/ |
1668 | /*****************************************************************************/ |
1665 | |
1669 | |
1666 | void |
1670 | void |
… | |
… | |
2429 | if (w->wd < 0) |
2433 | if (w->wd < 0) |
2430 | { |
2434 | { |
2431 | ev_timer_start (EV_A_ &w->timer); /* this is not race-free, so we still need to recheck periodically */ |
2435 | ev_timer_start (EV_A_ &w->timer); /* this is not race-free, so we still need to recheck periodically */ |
2432 | |
2436 | |
2433 | /* monitor some parent directory for speedup hints */ |
2437 | /* monitor some parent directory for speedup hints */ |
2434 | /* note that exceeding the hardcoded limit is not a correctness issue, */ |
2438 | /* note that exceeding the hardcoded path limit is not a correctness issue, */ |
2435 | /* but an efficiency issue only */ |
2439 | /* but an efficiency issue only */ |
2436 | if ((errno == ENOENT || errno == EACCES) && strlen (w->path) < 4096) |
2440 | if ((errno == ENOENT || errno == EACCES) && strlen (w->path) < 4096) |
2437 | { |
2441 | { |
2438 | char path [4096]; |
2442 | char path [4096]; |
2439 | strcpy (path, w->path); |
2443 | strcpy (path, w->path); |
… | |
… | |
2453 | } |
2457 | } |
2454 | while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); |
2458 | while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); |
2455 | } |
2459 | } |
2456 | } |
2460 | } |
2457 | else |
2461 | else |
|
|
2462 | todo, on nfs etc., we need to poll every 60s or so |
2458 | ev_timer_stop (EV_A_ &w->timer); /* we can watch this in a race-free way */ |
2463 | ev_timer_stop (EV_A_ &w->timer); /* we can watch this in a race-free way */ |
2459 | |
2464 | |
2460 | if (w->wd >= 0) |
2465 | if (w->wd >= 0) |
2461 | wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); |
2466 | wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); |
2462 | } |
2467 | } |