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

Comparing libev/ev.c (file contents):
Revision 1.320 by root, Fri Dec 4 20:25:06 2009 UTC vs.
Revision 1.325 by root, Sun Jan 24 12:31:55 2010 UTC

110# define EV_USE_EPOLL 0 110# define EV_USE_EPOLL 0
111# endif 111# endif
112# endif 112# endif
113 113
114# ifndef EV_USE_KQUEUE 114# ifndef EV_USE_KQUEUE
115# if HAVE_KQUEUE && HAVE_SYS_EVENT_H && HAVE_SYS_QUEUE_H 115# if HAVE_KQUEUE && HAVE_SYS_EVENT_H
116# define EV_USE_KQUEUE 1 116# define EV_USE_KQUEUE 1
117# else 117# else
118# define EV_USE_KQUEUE 0 118# define EV_USE_KQUEUE 0
119# endif 119# endif
120# endif 120# endif
344# endif 344# endif
345#endif 345#endif
346 346
347/* this block fixes any misconfiguration where we know we run into trouble otherwise */ 347/* this block fixes any misconfiguration where we know we run into trouble otherwise */
348 348
349#ifdef _AIX
350/* AIX has a completely broken poll.h header */
351# undef EV_USE_POLL
352# define EV_USE_POLL 0
353#endif
354
349#ifndef CLOCK_MONOTONIC 355#ifndef CLOCK_MONOTONIC
350# undef EV_USE_MONOTONIC 356# undef EV_USE_MONOTONIC
351# define EV_USE_MONOTONIC 0 357# define EV_USE_MONOTONIC 0
352#endif 358#endif
353 359
505 511
506#ifndef EV_FD_TO_WIN32_HANDLE 512#ifndef EV_FD_TO_WIN32_HANDLE
507# define EV_FD_TO_WIN32_HANDLE(fd) _get_osfhandle (fd) 513# define EV_FD_TO_WIN32_HANDLE(fd) _get_osfhandle (fd)
508#endif 514#endif
509#ifndef EV_WIN32_HANDLE_TO_FD 515#ifndef EV_WIN32_HANDLE_TO_FD
510# define EV_WIN32_HANDLE_TO_FD(handle) _open_osfhandle (fd, 0) 516# define EV_WIN32_HANDLE_TO_FD(handle) _open_osfhandle (handle, 0)
511#endif 517#endif
512#ifndef EV_WIN32_CLOSE_FD 518#ifndef EV_WIN32_CLOSE_FD
513# define EV_WIN32_CLOSE_FD(fd) close (fd) 519# define EV_WIN32_CLOSE_FD(fd) close (fd)
514#endif 520#endif
515 521
964/* check whether the given fd is atcually valid, for error recovery */ 970/* check whether the given fd is atcually valid, for error recovery */
965inline_size int 971inline_size int
966fd_valid (int fd) 972fd_valid (int fd)
967{ 973{
968#ifdef _WIN32 974#ifdef _WIN32
969 return _get_osfhandle (fd) != -1; 975 return EV_FD_TO_WIN32_HANDLE (fd) != -1;
970#else 976#else
971 return fcntl (fd, F_GETFD) != -1; 977 return fcntl (fd, F_GETFD) != -1;
972#endif 978#endif
973} 979}
974 980
1179inline_speed void 1185inline_speed void
1180fd_intern (int fd) 1186fd_intern (int fd)
1181{ 1187{
1182#ifdef _WIN32 1188#ifdef _WIN32
1183 unsigned long arg = 1; 1189 unsigned long arg = 1;
1184 ioctlsocket (_get_osfhandle (fd), FIONBIO, &arg); 1190 ioctlsocket (EV_FD_TO_WIN32_HANDLE (fd), FIONBIO, &arg);
1185#else 1191#else
1186 fcntl (fd, F_SETFD, FD_CLOEXEC); 1192 fcntl (fd, F_SETFD, FD_CLOEXEC);
1187 fcntl (fd, F_SETFL, O_NONBLOCK); 1193 fcntl (fd, F_SETFL, O_NONBLOCK);
1188#endif 1194#endif
1189} 1195}
1294{ 1300{
1295#if EV_MULTIPLICITY 1301#if EV_MULTIPLICITY
1296 EV_P = signals [signum - 1].loop; 1302 EV_P = signals [signum - 1].loop;
1297#endif 1303#endif
1298 1304
1299#if _WIN32 1305#ifdef _WIN32
1300 signal (signum, ev_sighandler); 1306 signal (signum, ev_sighandler);
1301#endif 1307#endif
1302 1308
1303 signals [signum - 1].pending = 1; 1309 signals [signum - 1].pending = 1;
1304 evpipe_write (EV_A_ &sig_pending); 1310 evpipe_write (EV_A_ &sig_pending);
1605#endif 1611#endif
1606#if EV_USE_INOTIFY 1612#if EV_USE_INOTIFY
1607 fs_fd = flags & EVFLAG_NOINOTIFY ? -1 : -2; 1613 fs_fd = flags & EVFLAG_NOINOTIFY ? -1 : -2;
1608#endif 1614#endif
1609#if EV_USE_SIGNALFD 1615#if EV_USE_SIGNALFD
1610 sigfd = flags & EVFLAG_NOSIGFD ? -1 : -2; 1616 sigfd = flags & EVFLAG_SIGNALFD ? -2 : -1;
1611#endif 1617#endif
1612 1618
1613 if (!(flags & 0x0000ffffU)) 1619 if (!(flags & 0x0000ffffU))
1614 flags |= ev_recommended_backends (); 1620 flags |= ev_recommended_backends ();
1615 1621
2157 ANHE_at_cache (*he); 2163 ANHE_at_cache (*he);
2158 } 2164 }
2159} 2165}
2160 2166
2161/* fetch new monotonic and realtime times from the kernel */ 2167/* fetch new monotonic and realtime times from the kernel */
2162/* also detetc if there was a timejump, and act accordingly */ 2168/* also detect if there was a timejump, and act accordingly */
2163inline_speed void 2169inline_speed void
2164time_update (EV_P_ ev_tstamp max_block) 2170time_update (EV_P_ ev_tstamp max_block)
2165{ 2171{
2166#if EV_USE_MONOTONIC 2172#if EV_USE_MONOTONIC
2167 if (expect_true (have_monotonic)) 2173 if (expect_true (have_monotonic))
2747 if (!((WL)w)->next) 2753 if (!((WL)w)->next)
2748# if EV_USE_SIGNALFD 2754# if EV_USE_SIGNALFD
2749 if (sigfd < 0) /*TODO*/ 2755 if (sigfd < 0) /*TODO*/
2750# endif 2756# endif
2751 { 2757 {
2752# if _WIN32 2758# ifdef _WIN32
2753 evpipe_init (EV_A); 2759 evpipe_init (EV_A);
2754 2760
2755 signal (w->signum, ev_sighandler); 2761 signal (w->signum, ev_sighandler);
2756# else 2762# else
2757 struct sigaction sa; 2763 struct sigaction sa;
2790 signals [w->signum - 1].loop = 0; /* unattach from signal */ 2796 signals [w->signum - 1].loop = 0; /* unattach from signal */
2791#endif 2797#endif
2792#if EV_USE_SIGNALFD 2798#if EV_USE_SIGNALFD
2793 if (sigfd >= 0) 2799 if (sigfd >= 0)
2794 { 2800 {
2795 sigprocmask (SIG_UNBLOCK, &sigfd_set, 0);//D 2801 sigset_t ss;
2802
2803 sigemptyset (&ss);
2804 sigaddset (&ss, w->signum);
2796 sigdelset (&sigfd_set, w->signum); 2805 sigdelset (&sigfd_set, w->signum);
2806
2797 signalfd (sigfd, &sigfd_set, 0); 2807 signalfd (sigfd, &sigfd_set, 0);
2798 sigprocmask (SIG_BLOCK, &sigfd_set, 0);//D 2808 sigprocmask (SIG_UNBLOCK, &ss, 0);
2799 /*TODO: maybe unblock signal? */
2800 } 2809 }
2801 else 2810 else
2802#endif 2811#endif
2803 signal (w->signum, SIG_DFL); 2812 signal (w->signum, SIG_DFL);
2804 } 2813 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines