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

Comparing libev/ev.c (file contents):
Revision 1.211 by root, Tue Feb 19 17:09:28 2008 UTC vs.
Revision 1.214 by root, Tue Feb 19 19:21:20 2008 UTC

811 fd_intern (evpipe [1]); 811 fd_intern (evpipe [1]);
812 812
813 ev_io_set (&pipeev, evpipe [0], EV_READ); 813 ev_io_set (&pipeev, evpipe [0], EV_READ);
814 ev_io_start (EV_A_ &pipeev); 814 ev_io_start (EV_A_ &pipeev);
815 ev_unref (EV_A); /* watcher should not keep loop alive */ 815 ev_unref (EV_A); /* watcher should not keep loop alive */
816
817 /* in case we received the signal before we had the chance of installing a handler */
818 ev_feed_event (EV_A_ &pipeev, 0);
819 } 816 }
820} 817}
821 818
822void inline_size 819void inline_size
823evpipe_write (EV_P_ int sig, int async) 820evpipe_write (EV_P_ EV_ATOMIC_T *flag)
824{ 821{
825 if (!(gotasync || gotsig)) 822 if (!*flag)
826 { 823 {
827 int old_errno = errno; /* save errno becaue write might clobber it */ 824 int old_errno = errno; /* save errno becaue write might clobber it */
828 825
829 if (sig) gotsig = 1; 826 *flag = 1;
830 if (async) gotasync = 1;
831
832 write (evpipe [1], &old_errno, 1); 827 write (evpipe [1], &old_errno, 1);
833 828
834 errno = old_errno; 829 errno = old_errno;
835 } 830 }
836} 831}
881#if _WIN32 876#if _WIN32
882 signal (signum, sighandler); 877 signal (signum, sighandler);
883#endif 878#endif
884 879
885 signals [signum - 1].gotsig = 1; 880 signals [signum - 1].gotsig = 1;
886 evpipe_write (EV_A_ 1, 0); 881 evpipe_write (EV_A_ &gotsig);
887} 882}
888 883
889void noinline 884void noinline
890ev_feed_signal_event (EV_P_ int signum) 885ev_feed_signal_event (EV_P_ int signum)
891{ 886{
1221#endif 1216#endif
1222 1217
1223 if (ev_is_active (&pipeev)) 1218 if (ev_is_active (&pipeev))
1224 { 1219 {
1225 /* 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
1226 gotsig = gotasync = 1; 1224 gotasync = 1;
1225#endif
1227 1226
1228 ev_ref (EV_A); 1227 ev_ref (EV_A);
1229 ev_io_stop (EV_A_ &pipeev); 1228 ev_io_stop (EV_A_ &pipeev);
1230 close (evpipe [0]); 1229 close (evpipe [0]);
1231 close (evpipe [1]); 1230 close (evpipe [1]);
2467 2466
2468void 2467void
2469ev_async_send (EV_P_ ev_async *w) 2468ev_async_send (EV_P_ ev_async *w)
2470{ 2469{
2471 w->sent = 1; 2470 w->sent = 1;
2472 evpipe_write (EV_A_ 0, 1); 2471 evpipe_write (EV_A_ &gotasync);
2473} 2472}
2474#endif 2473#endif
2475 2474
2476/*****************************************************************************/ 2475/*****************************************************************************/
2477 2476

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines