ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.315 by root, Wed Aug 26 17:46:22 2009 UTC vs.
Revision 1.317 by root, Sat Nov 14 00:15:21 2009 UTC

450 */ 450 */
451#define TIME_EPSILON 0.0001220703125 /* 1/8192 */ 451#define TIME_EPSILON 0.0001220703125 /* 1/8192 */
452 452
453#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */ 453#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */
454#define MAX_BLOCKTIME 59.743 /* never wait longer than this time (to detect time jumps) */ 454#define MAX_BLOCKTIME 59.743 /* never wait longer than this time (to detect time jumps) */
455/*#define CLEANUP_INTERVAL (MAX_BLOCKTIME * 5.) /* how often to try to free memory and re-check fds, TODO */
456 455
457#if __GNUC__ >= 4 456#if __GNUC__ >= 4
458# define expect(expr,value) __builtin_expect ((expr),(value)) 457# define expect(expr,value) __builtin_expect ((expr),(value))
459# define noinline __attribute__ ((noinline)) 458# define noinline __attribute__ ((noinline))
460#else 459#else
1659 } 1658 }
1660 } 1659 }
1661 1660
1662#if EV_USE_SIGNALFD 1661#if EV_USE_SIGNALFD
1663 if (ev_is_active (&sigfd_w)) 1662 if (ev_is_active (&sigfd_w))
1664 {
1665 /*ev_ref (EV_A);*/
1666 /*ev_io_stop (EV_A_ &sigfd_w);*/
1667
1668 close (sigfd); 1663 close (sigfd);
1669 }
1670#endif 1664#endif
1671 1665
1672#if EV_USE_INOTIFY 1666#if EV_USE_INOTIFY
1673 if (fs_fd >= 0) 1667 if (fs_fd >= 0)
1674 close (fs_fd); 1668 close (fs_fd);
2753# if EV_USE_SIGNALFD 2747# if EV_USE_SIGNALFD
2754 if (sigfd < 0) /*TODO*/ 2748 if (sigfd < 0) /*TODO*/
2755# endif 2749# endif
2756 { 2750 {
2757# if _WIN32 2751# if _WIN32
2752 evpipe_init (EV_A);
2753
2758 signal (w->signum, ev_sighandler); 2754 signal (w->signum, ev_sighandler);
2759# else 2755# else
2760 struct sigaction sa; 2756 struct sigaction sa;
2761 2757
2762 evpipe_init (EV_A); 2758 evpipe_init (EV_A);
2897 struct statfs sfs; 2893 struct statfs sfs;
2898 2894
2899 wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); 2895 wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w);
2900 2896
2901 /* now local changes will be tracked by inotify, but remote changes won't */ 2897 /* now local changes will be tracked by inotify, but remote changes won't */
2902 /* unless the filesystem it known to be local, we therefore still poll */ 2898 /* unless the filesystem is known to be local, we therefore still poll */
2903 /* also do poll on <2.6.25, but with normal frequency */ 2899 /* also do poll on <2.6.25, but with normal frequency */
2904 2900
2905 if (fs_2625 && !statfs (w->path, &sfs)) 2901 if (fs_2625 && !statfs (w->path, &sfs))
2906 if (sfs.f_type == 0x1373 /* devfs */ 2902 if (sfs.f_type == 0x1373 /* devfs */
2907 || sfs.f_type == 0xEF53 /* ext2/3 */ 2903 || sfs.f_type == 0xEF53 /* ext2/3 */
3026 { 3022 {
3027 fd_intern (fs_fd); 3023 fd_intern (fs_fd);
3028 ev_io_init (&fs_w, infy_cb, fs_fd, EV_READ); 3024 ev_io_init (&fs_w, infy_cb, fs_fd, EV_READ);
3029 ev_set_priority (&fs_w, EV_MAXPRI); 3025 ev_set_priority (&fs_w, EV_MAXPRI);
3030 ev_io_start (EV_A_ &fs_w); 3026 ev_io_start (EV_A_ &fs_w);
3027 ev_unref (EV_A);
3031 } 3028 }
3032} 3029}
3033 3030
3034inline_size void 3031inline_size void
3035infy_fork (EV_P) 3032infy_fork (EV_P)
3037 int slot; 3034 int slot;
3038 3035
3039 if (fs_fd < 0) 3036 if (fs_fd < 0)
3040 return; 3037 return;
3041 3038
3039 ev_ref (EV_A);
3042 ev_io_stop (EV_A_ &fs_w); 3040 ev_io_stop (EV_A_ &fs_w);
3043 close (fs_fd); 3041 close (fs_fd);
3044 fs_fd = infy_newfd (); 3042 fs_fd = infy_newfd ();
3045 3043
3046 if (fs_fd >= 0) 3044 if (fs_fd >= 0)
3047 { 3045 {
3048 fd_intern (fs_fd); 3046 fd_intern (fs_fd);
3049 ev_io_set (&fs_w, fs_fd, EV_READ); 3047 ev_io_set (&fs_w, fs_fd, EV_READ);
3050 ev_io_start (EV_A_ &fs_w); 3048 ev_io_start (EV_A_ &fs_w);
3049 ev_unref (EV_A);
3051 } 3050 }
3052 3051
3053 for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot) 3052 for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot)
3054 { 3053 {
3055 WL w_ = fs_hash [slot].head; 3054 WL w_ = fs_hash [slot].head;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines