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

Comparing libev/ev.c (file contents):
Revision 1.207 by root, Thu Jan 31 13:10:56 2008 UTC vs.
Revision 1.212 by root, Tue Feb 19 19:01:13 2008 UTC

810 fd_intern (evpipe [0]); 810 fd_intern (evpipe [0]);
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); /* child 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_ int sig, int async)
821{ 821{
822 if (!(gotasync || gotsig)) 822 if (!(gotasync || gotsig))
823 { 823 {
824 int old_errno = errno; 824 int old_errno = errno; /* save errno becaue write might clobber it */
825 825
826 if (sig) gotsig = 1; 826 if (sig) gotsig = 1;
827 if (async) gotasync = 1; 827 if (async) gotasync = 1;
828 828
829 write (evpipe [1], &old_errno, 1); 829 write (evpipe [1], &old_errno, 1);
830
830 errno = old_errno; 831 errno = old_errno;
831 } 832 }
832} 833}
833 834
834static void 835static void
837 { 838 {
838 int dummy; 839 int dummy;
839 read (evpipe [0], &dummy, 1); 840 read (evpipe [0], &dummy, 1);
840 } 841 }
841 842
842 if (gotsig) 843 if (gotsig && ev_is_default_loop (EV_A))
843 { 844 {
844 int signum; 845 int signum;
845 gotsig = 0; 846 gotsig = 0;
846 847
847 for (signum = signalmax; signum--; ) 848 for (signum = signalmax; signum--; )
848 if (signals [signum].gotsig) 849 if (signals [signum].gotsig)
849 ev_feed_signal_event (EV_A_ signum + 1); 850 ev_feed_signal_event (EV_A_ signum + 1);
850 } 851 }
851 852
853#if EV_ASYNC_ENABLE
852 if (gotasync) 854 if (gotasync)
853 { 855 {
854 int i; 856 int i;
855 gotasync = 0; 857 gotasync = 0;
856 858
859 { 861 {
860 asyncs [i]->sent = 0; 862 asyncs [i]->sent = 0;
861 ev_feed_event (EV_A_ asyncs [i], EV_ASYNC); 863 ev_feed_event (EV_A_ asyncs [i], EV_ASYNC);
862 } 864 }
863 } 865 }
866#endif
864} 867}
865 868
866/*****************************************************************************/ 869/*****************************************************************************/
867 870
868static void 871static void
1079 if (!clock_gettime (CLOCK_MONOTONIC, &ts)) 1082 if (!clock_gettime (CLOCK_MONOTONIC, &ts))
1080 have_monotonic = 1; 1083 have_monotonic = 1;
1081 } 1084 }
1082#endif 1085#endif
1083 1086
1084 ev_rt_now = ev_time (); 1087 ev_rt_now = ev_time ();
1085 mn_now = get_clock (); 1088 mn_now = get_clock ();
1086 now_floor = mn_now; 1089 now_floor = mn_now;
1087 rtmn_diff = ev_rt_now - mn_now; 1090 rtmn_diff = ev_rt_now - mn_now;
1088 1091
1089 io_blocktime = 0.; 1092 io_blocktime = 0.;
1090 timeout_blocktime = 0.; 1093 timeout_blocktime = 0.;
1094 backend = 0;
1095 backend_fd = -1;
1096 gotasync = 0;
1097#if EV_USE_INOTIFY
1098 fs_fd = -2;
1099#endif
1091 1100
1092 /* pid check not overridable via env */ 1101 /* pid check not overridable via env */
1093#ifndef _WIN32 1102#ifndef _WIN32
1094 if (flags & EVFLAG_FORKCHECK) 1103 if (flags & EVFLAG_FORKCHECK)
1095 curpid = getpid (); 1104 curpid = getpid ();
1100 && getenv ("LIBEV_FLAGS")) 1109 && getenv ("LIBEV_FLAGS"))
1101 flags = atoi (getenv ("LIBEV_FLAGS")); 1110 flags = atoi (getenv ("LIBEV_FLAGS"));
1102 1111
1103 if (!(flags & 0x0000ffffUL)) 1112 if (!(flags & 0x0000ffffUL))
1104 flags |= ev_recommended_backends (); 1113 flags |= ev_recommended_backends ();
1105
1106 backend = 0;
1107 backend_fd = -1;
1108#if EV_USE_INOTIFY
1109 fs_fd = -2;
1110#endif
1111 1114
1112#if EV_USE_PORT 1115#if EV_USE_PORT
1113 if (!backend && (flags & EVBACKEND_PORT )) backend = port_init (EV_A_ flags); 1116 if (!backend && (flags & EVBACKEND_PORT )) backend = port_init (EV_A_ flags);
1114#endif 1117#endif
1115#if EV_USE_KQUEUE 1118#if EV_USE_KQUEUE
1187#if EV_FORK_ENABLE 1190#if EV_FORK_ENABLE
1188 array_free (fork, EMPTY); 1191 array_free (fork, EMPTY);
1189#endif 1192#endif
1190 array_free (prepare, EMPTY); 1193 array_free (prepare, EMPTY);
1191 array_free (check, EMPTY); 1194 array_free (check, EMPTY);
1195#if EV_ASYNC_ENABLE
1196 array_free (async, EMPTY);
1197#endif
1192 1198
1193 backend = 0; 1199 backend = 0;
1194} 1200}
1195 1201
1196void inline_size infy_fork (EV_P); 1202void inline_size infy_fork (EV_P);
1212#endif 1218#endif
1213 1219
1214 if (ev_is_active (&pipeev)) 1220 if (ev_is_active (&pipeev))
1215 { 1221 {
1216 /* this "locks" the handlers against writing to the pipe */ 1222 /* this "locks" the handlers against writing to the pipe */
1223 /* while we modify the fd vars */
1224 gotsig = 1;
1225#if EV_ASYNC_ENABLE
1217 gotsig = gotasync = 1; 1226 gotasync = 1;
1227#endif
1218 1228
1219 ev_ref (EV_A); 1229 ev_ref (EV_A);
1220 ev_io_stop (EV_A_ &pipeev); 1230 ev_io_stop (EV_A_ &pipeev);
1221 close (evpipe [0]); 1231 close (evpipe [0]);
1222 close (evpipe [1]); 1232 close (evpipe [1]);
1223 1233
1224 evpipe_init (EV_A); 1234 evpipe_init (EV_A);
1225 /* now iterate over everything */ 1235 /* now iterate over everything, in case we missed something */
1226 evcb (EV_A_ &pipeev, EV_READ); 1236 pipecb (EV_A_ &pipeev, EV_READ);
1227 } 1237 }
1228 1238
1229 postfork = 0; 1239 postfork = 0;
1230} 1240}
1231 1241

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines