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

Comparing libev/ev.c (file contents):
Revision 1.318 by root, Tue Nov 17 00:22:28 2009 UTC vs.
Revision 1.321 by root, Thu Dec 31 06:50:17 2009 UTC

153 153
154#endif 154#endif
155 155
156#include <math.h> 156#include <math.h>
157#include <stdlib.h> 157#include <stdlib.h>
158#include <string.h>
158#include <fcntl.h> 159#include <fcntl.h>
159#include <stddef.h> 160#include <stddef.h>
160 161
161#include <stdio.h> 162#include <stdio.h>
162 163
1604#endif 1605#endif
1605#if EV_USE_INOTIFY 1606#if EV_USE_INOTIFY
1606 fs_fd = flags & EVFLAG_NOINOTIFY ? -1 : -2; 1607 fs_fd = flags & EVFLAG_NOINOTIFY ? -1 : -2;
1607#endif 1608#endif
1608#if EV_USE_SIGNALFD 1609#if EV_USE_SIGNALFD
1609 sigfd = flags & EVFLAG_NOSIGFD ? -1 : -2; 1610 sigfd = flags & EVFLAG_SIGNALFD ? -2 : -1;
1610#endif 1611#endif
1611 1612
1612 if (!(flags & 0x0000ffffU)) 1613 if (!(flags & 0x0000ffffU))
1613 flags |= ev_recommended_backends (); 1614 flags |= ev_recommended_backends ();
1614 1615
2789 signals [w->signum - 1].loop = 0; /* unattach from signal */ 2790 signals [w->signum - 1].loop = 0; /* unattach from signal */
2790#endif 2791#endif
2791#if EV_USE_SIGNALFD 2792#if EV_USE_SIGNALFD
2792 if (sigfd >= 0) 2793 if (sigfd >= 0)
2793 { 2794 {
2794 sigprocmask (SIG_UNBLOCK, &sigfd_set, 0);//D 2795 sigset_t ss;
2796
2797 sigemptyset (&ss);
2798 sigaddset (&ss, w->signum);
2795 sigdelset (&sigfd_set, w->signum); 2799 sigdelset (&sigfd_set, w->signum);
2800
2796 signalfd (sigfd, &sigfd_set, 0); 2801 signalfd (sigfd, &sigfd_set, 0);
2797 sigprocmask (SIG_BLOCK, &sigfd_set, 0);//D 2802 sigprocmask (SIG_UNBLOCK, &ss, 0);
2798 /*TODO: maybe unblock signal? */
2799 } 2803 }
2800 else 2804 else
2801#endif 2805#endif
2802 signal (w->signum, SIG_DFL); 2806 signal (w->signum, SIG_DFL);
2803 } 2807 }
3100static void noinline 3104static void noinline
3101stat_timer_cb (EV_P_ ev_timer *w_, int revents) 3105stat_timer_cb (EV_P_ ev_timer *w_, int revents)
3102{ 3106{
3103 ev_stat *w = (ev_stat *)(((char *)w_) - offsetof (ev_stat, timer)); 3107 ev_stat *w = (ev_stat *)(((char *)w_) - offsetof (ev_stat, timer));
3104 3108
3105 /* we copy this here each the time so that */ 3109 ev_statdata prev = w->attr;
3106 /* prev has the old value when the callback gets invoked */
3107 w->prev = w->attr;
3108 ev_stat_stat (EV_A_ w); 3110 ev_stat_stat (EV_A_ w);
3109 3111
3110 /* memcmp doesn't work on netbsd, they.... do stuff to their struct stat */ 3112 /* memcmp doesn't work on netbsd, they.... do stuff to their struct stat */
3111 if ( 3113 if (
3112 w->prev.st_dev != w->attr.st_dev 3114 prev.st_dev != w->attr.st_dev
3113 || w->prev.st_ino != w->attr.st_ino 3115 || prev.st_ino != w->attr.st_ino
3114 || w->prev.st_mode != w->attr.st_mode 3116 || prev.st_mode != w->attr.st_mode
3115 || w->prev.st_nlink != w->attr.st_nlink 3117 || prev.st_nlink != w->attr.st_nlink
3116 || w->prev.st_uid != w->attr.st_uid 3118 || prev.st_uid != w->attr.st_uid
3117 || w->prev.st_gid != w->attr.st_gid 3119 || prev.st_gid != w->attr.st_gid
3118 || w->prev.st_rdev != w->attr.st_rdev 3120 || prev.st_rdev != w->attr.st_rdev
3119 || w->prev.st_size != w->attr.st_size 3121 || prev.st_size != w->attr.st_size
3120 || w->prev.st_atime != w->attr.st_atime 3122 || prev.st_atime != w->attr.st_atime
3121 || w->prev.st_mtime != w->attr.st_mtime 3123 || prev.st_mtime != w->attr.st_mtime
3122 || w->prev.st_ctime != w->attr.st_ctime 3124 || prev.st_ctime != w->attr.st_ctime
3123 ) { 3125 ) {
3126 /* we only update w->prev on actual differences */
3127 /* in case we test more often than invoke the callback, */
3128 /* to ensure that prev is always different to attr */
3129 w->prev = prev;
3130
3124 #if EV_USE_INOTIFY 3131 #if EV_USE_INOTIFY
3125 if (fs_fd >= 0) 3132 if (fs_fd >= 0)
3126 { 3133 {
3127 infy_del (EV_A_ w); 3134 infy_del (EV_A_ w);
3128 infy_add (EV_A_ w); 3135 infy_add (EV_A_ w);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines