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

Comparing libev/ev.c (file contents):
Revision 1.210 by root, Sat Feb 9 00:34:11 2008 UTC vs.
Revision 1.214 by root, Tue Feb 19 19:21:20 2008 UTC

815 ev_unref (EV_A); /* watcher should not keep loop alive */ 815 ev_unref (EV_A); /* watcher should not keep loop alive */
816 } 816 }
817} 817}
818 818
819void inline_size 819void inline_size
820evpipe_write (EV_P_ int sig, int async) 820evpipe_write (EV_P_ EV_ATOMIC_T *flag)
821{ 821{
822 if (!(gotasync || gotsig)) 822 if (!*flag)
823 { 823 {
824 int old_errno = errno; /* save errno becaue write might clobber it */ 824 int old_errno = errno; /* save errno becaue write might clobber it */
825 825
826 if (sig) gotsig = 1; 826 *flag = 1;
827 if (async) gotasync = 1;
828
829 write (evpipe [1], &old_errno, 1); 827 write (evpipe [1], &old_errno, 1);
830 828
831 errno = old_errno; 829 errno = old_errno;
832 } 830 }
833} 831}
838 { 836 {
839 int dummy; 837 int dummy;
840 read (evpipe [0], &dummy, 1); 838 read (evpipe [0], &dummy, 1);
841 } 839 }
842 840
843 if (gotsig) 841 if (gotsig && ev_is_default_loop (EV_A))
844 { 842 {
845 int signum; 843 int signum;
846 gotsig = 0; 844 gotsig = 0;
847 845
848 for (signum = signalmax; signum--; ) 846 for (signum = signalmax; signum--; )
878#if _WIN32 876#if _WIN32
879 signal (signum, sighandler); 877 signal (signum, sighandler);
880#endif 878#endif
881 879
882 signals [signum - 1].gotsig = 1; 880 signals [signum - 1].gotsig = 1;
883 evpipe_write (EV_A_ 1, 0); 881 evpipe_write (EV_A_ &gotsig);
884} 882}
885 883
886void noinline 884void noinline
887ev_feed_signal_event (EV_P_ int signum) 885ev_feed_signal_event (EV_P_ int signum)
888{ 886{
1218#endif 1216#endif
1219 1217
1220 if (ev_is_active (&pipeev)) 1218 if (ev_is_active (&pipeev))
1221 { 1219 {
1222 /* this "locks" the handlers against writing to the pipe */ 1220 /* this "locks" the handlers against writing to the pipe */
1221 /* while we modify the fd vars */
1222 gotsig = 1;
1223#if EV_ASYNC_ENABLE
1223 gotsig = gotasync = 1; 1224 gotasync = 1;
1225#endif
1224 1226
1225 ev_ref (EV_A); 1227 ev_ref (EV_A);
1226 ev_io_stop (EV_A_ &pipeev); 1228 ev_io_stop (EV_A_ &pipeev);
1227 close (evpipe [0]); 1229 close (evpipe [0]);
1228 close (evpipe [1]); 1230 close (evpipe [1]);
2464 2466
2465void 2467void
2466ev_async_send (EV_P_ ev_async *w) 2468ev_async_send (EV_P_ ev_async *w)
2467{ 2469{
2468 w->sent = 1; 2470 w->sent = 1;
2469 evpipe_write (EV_A_ 0, 1); 2471 evpipe_write (EV_A_ &gotasync);
2470} 2472}
2471#endif 2473#endif
2472 2474
2473/*****************************************************************************/ 2475/*****************************************************************************/
2474 2476

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines