… | |
… | |
39 | |
39 | |
40 | #ifdef __cplusplus |
40 | #ifdef __cplusplus |
41 | extern "C" { |
41 | extern "C" { |
42 | #endif |
42 | #endif |
43 | |
43 | |
|
|
44 | /* this big block deduces configuration from config.h */ |
44 | #ifndef EV_STANDALONE |
45 | #ifndef EV_STANDALONE |
45 | # ifdef EV_CONFIG_H |
46 | # ifdef EV_CONFIG_H |
46 | # include EV_CONFIG_H |
47 | # include EV_CONFIG_H |
47 | # else |
48 | # else |
48 | # include "config.h" |
49 | # include "config.h" |
… | |
… | |
118 | # else |
119 | # else |
119 | # define EV_USE_INOTIFY 0 |
120 | # define EV_USE_INOTIFY 0 |
120 | # endif |
121 | # endif |
121 | # endif |
122 | # endif |
122 | |
123 | |
|
|
124 | # ifndef EV_USE_EVENTFD |
|
|
125 | # if HAVE_EVENTFD |
|
|
126 | # define EV_USE_EVENTFD 1 |
|
|
127 | # else |
|
|
128 | # define EV_USE_EVENTFD 0 |
|
|
129 | # endif |
|
|
130 | # endif |
|
|
131 | |
123 | #endif |
132 | #endif |
124 | |
133 | |
125 | #include <math.h> |
134 | #include <math.h> |
126 | #include <stdlib.h> |
135 | #include <stdlib.h> |
127 | #include <fcntl.h> |
136 | #include <fcntl.h> |
… | |
… | |
152 | # ifndef EV_SELECT_IS_WINSOCKET |
161 | # ifndef EV_SELECT_IS_WINSOCKET |
153 | # define EV_SELECT_IS_WINSOCKET 1 |
162 | # define EV_SELECT_IS_WINSOCKET 1 |
154 | # endif |
163 | # endif |
155 | #endif |
164 | #endif |
156 | |
165 | |
157 | /**/ |
166 | /* this block tries to deduce configuration from header-defined symbols and defaults */ |
158 | |
167 | |
159 | #ifndef EV_USE_MONOTONIC |
168 | #ifndef EV_USE_MONOTONIC |
160 | # define EV_USE_MONOTONIC 0 |
169 | # define EV_USE_MONOTONIC 0 |
161 | #endif |
170 | #endif |
162 | |
171 | |
… | |
… | |
179 | # define EV_USE_POLL 1 |
188 | # define EV_USE_POLL 1 |
180 | # endif |
189 | # endif |
181 | #endif |
190 | #endif |
182 | |
191 | |
183 | #ifndef EV_USE_EPOLL |
192 | #ifndef EV_USE_EPOLL |
|
|
193 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) |
|
|
194 | # define EV_USE_EPOLL 1 |
|
|
195 | # else |
184 | # define EV_USE_EPOLL 0 |
196 | # define EV_USE_EPOLL 0 |
|
|
197 | # endif |
185 | #endif |
198 | #endif |
186 | |
199 | |
187 | #ifndef EV_USE_KQUEUE |
200 | #ifndef EV_USE_KQUEUE |
188 | # define EV_USE_KQUEUE 0 |
201 | # define EV_USE_KQUEUE 0 |
189 | #endif |
202 | #endif |
… | |
… | |
191 | #ifndef EV_USE_PORT |
204 | #ifndef EV_USE_PORT |
192 | # define EV_USE_PORT 0 |
205 | # define EV_USE_PORT 0 |
193 | #endif |
206 | #endif |
194 | |
207 | |
195 | #ifndef EV_USE_INOTIFY |
208 | #ifndef EV_USE_INOTIFY |
|
|
209 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) |
|
|
210 | # define EV_USE_INOTIFY 1 |
|
|
211 | # else |
196 | # define EV_USE_INOTIFY 0 |
212 | # define EV_USE_INOTIFY 0 |
|
|
213 | # endif |
197 | #endif |
214 | #endif |
198 | |
215 | |
199 | #ifndef EV_PID_HASHSIZE |
216 | #ifndef EV_PID_HASHSIZE |
200 | # if EV_MINIMAL |
217 | # if EV_MINIMAL |
201 | # define EV_PID_HASHSIZE 1 |
218 | # define EV_PID_HASHSIZE 1 |
… | |
… | |
210 | # else |
227 | # else |
211 | # define EV_INOTIFY_HASHSIZE 16 |
228 | # define EV_INOTIFY_HASHSIZE 16 |
212 | # endif |
229 | # endif |
213 | #endif |
230 | #endif |
214 | |
231 | |
215 | /**/ |
232 | #ifndef EV_USE_EVENTFD |
|
|
233 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) |
|
|
234 | # define EV_USE_EVENTFD 1 |
|
|
235 | # else |
|
|
236 | # define EV_USE_EVENTFD 0 |
|
|
237 | # endif |
|
|
238 | #endif |
|
|
239 | |
|
|
240 | /* this block fixes any misconfiguration where we know we run into trouble otherwise */ |
216 | |
241 | |
217 | #ifndef CLOCK_MONOTONIC |
242 | #ifndef CLOCK_MONOTONIC |
218 | # undef EV_USE_MONOTONIC |
243 | # undef EV_USE_MONOTONIC |
219 | # define EV_USE_MONOTONIC 0 |
244 | # define EV_USE_MONOTONIC 0 |
220 | #endif |
245 | #endif |
… | |
… | |
239 | # include <sys/inotify.h> |
264 | # include <sys/inotify.h> |
240 | #endif |
265 | #endif |
241 | |
266 | |
242 | #if EV_SELECT_IS_WINSOCKET |
267 | #if EV_SELECT_IS_WINSOCKET |
243 | # include <winsock.h> |
268 | # include <winsock.h> |
|
|
269 | #endif |
|
|
270 | |
|
|
271 | #if EV_USE_EVENTFD |
|
|
272 | /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ |
|
|
273 | # include <stdint.h> |
|
|
274 | # ifdef __cplusplus |
|
|
275 | extern "C" { |
|
|
276 | # endif |
|
|
277 | int eventfd (unsigned int initval, int flags); |
|
|
278 | # ifdef __cplusplus |
|
|
279 | } |
|
|
280 | # endif |
244 | #endif |
281 | #endif |
245 | |
282 | |
246 | /**/ |
283 | /**/ |
247 | |
284 | |
248 | /* |
285 | /* |
… | |
… | |
263 | # define expect(expr,value) __builtin_expect ((expr),(value)) |
300 | # define expect(expr,value) __builtin_expect ((expr),(value)) |
264 | # define noinline __attribute__ ((noinline)) |
301 | # define noinline __attribute__ ((noinline)) |
265 | #else |
302 | #else |
266 | # define expect(expr,value) (expr) |
303 | # define expect(expr,value) (expr) |
267 | # define noinline |
304 | # define noinline |
268 | # if __STDC_VERSION__ < 199901L |
305 | # if __STDC_VERSION__ < 199901L && __GNUC__ < 2 |
269 | # define inline |
306 | # define inline |
270 | # endif |
307 | # endif |
271 | #endif |
308 | #endif |
272 | |
309 | |
273 | #define expect_false(expr) expect ((expr) != 0, 0) |
310 | #define expect_false(expr) expect ((expr) != 0, 0) |
… | |
… | |
323 | perror (msg); |
360 | perror (msg); |
324 | abort (); |
361 | abort (); |
325 | } |
362 | } |
326 | } |
363 | } |
327 | |
364 | |
|
|
365 | static void * |
|
|
366 | ev_realloc_emul (void *ptr, long size) |
|
|
367 | { |
|
|
368 | /* some systems, notably openbsd and darwin, fail to properly |
|
|
369 | * implement realloc (x, 0) (as required by both ansi c-98 and |
|
|
370 | * the single unix specification, so work around them here. |
|
|
371 | */ |
|
|
372 | |
|
|
373 | if (size) |
|
|
374 | return realloc (ptr, size); |
|
|
375 | |
|
|
376 | free (ptr); |
|
|
377 | return 0; |
|
|
378 | } |
|
|
379 | |
328 | static void *(*alloc)(void *ptr, long size); |
380 | static void *(*alloc)(void *ptr, long size) = ev_realloc_emul; |
329 | |
381 | |
330 | void |
382 | void |
331 | ev_set_allocator (void *(*cb)(void *ptr, long size)) |
383 | ev_set_allocator (void *(*cb)(void *ptr, long size)) |
332 | { |
384 | { |
333 | alloc = cb; |
385 | alloc = cb; |
334 | } |
386 | } |
335 | |
387 | |
336 | inline_speed void * |
388 | inline_speed void * |
337 | ev_realloc (void *ptr, long size) |
389 | ev_realloc (void *ptr, long size) |
338 | { |
390 | { |
339 | ptr = alloc ? alloc (ptr, size) : realloc (ptr, size); |
391 | ptr = alloc (ptr, size); |
340 | |
392 | |
341 | if (!ptr && size) |
393 | if (!ptr && size) |
342 | { |
394 | { |
343 | fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); |
395 | fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); |
344 | abort (); |
396 | abort (); |
… | |
… | |
451 | ts.tv_sec = (time_t)delay; |
503 | ts.tv_sec = (time_t)delay; |
452 | ts.tv_nsec = (long)((delay - (ev_tstamp)(ts.tv_sec)) * 1e9); |
504 | ts.tv_nsec = (long)((delay - (ev_tstamp)(ts.tv_sec)) * 1e9); |
453 | |
505 | |
454 | nanosleep (&ts, 0); |
506 | nanosleep (&ts, 0); |
455 | #elif defined(_WIN32) |
507 | #elif defined(_WIN32) |
456 | Sleep (delay * 1e3); |
508 | Sleep ((unsigned long)(delay * 1e3)); |
457 | #else |
509 | #else |
458 | struct timeval tv; |
510 | struct timeval tv; |
459 | |
511 | |
460 | tv.tv_sec = (time_t)delay; |
512 | tv.tv_sec = (time_t)delay; |
461 | tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6); |
513 | tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6); |
… | |
… | |
802 | static void noinline |
854 | static void noinline |
803 | evpipe_init (EV_P) |
855 | evpipe_init (EV_P) |
804 | { |
856 | { |
805 | if (!ev_is_active (&pipeev)) |
857 | if (!ev_is_active (&pipeev)) |
806 | { |
858 | { |
|
|
859 | #if EV_USE_EVENTFD |
|
|
860 | if ((evfd = eventfd (0, 0)) >= 0) |
|
|
861 | { |
|
|
862 | evpipe [0] = -1; |
|
|
863 | fd_intern (evfd); |
|
|
864 | ev_io_set (&pipeev, evfd, EV_READ); |
|
|
865 | } |
|
|
866 | else |
|
|
867 | #endif |
|
|
868 | { |
807 | while (pipe (evpipe)) |
869 | while (pipe (evpipe)) |
808 | syserr ("(libev) error creating signal/async pipe"); |
870 | syserr ("(libev) error creating signal/async pipe"); |
809 | |
871 | |
810 | fd_intern (evpipe [0]); |
872 | fd_intern (evpipe [0]); |
811 | fd_intern (evpipe [1]); |
873 | fd_intern (evpipe [1]); |
812 | |
|
|
813 | ev_io_set (&pipeev, evpipe [0], EV_READ); |
874 | ev_io_set (&pipeev, evpipe [0], EV_READ); |
|
|
875 | } |
|
|
876 | |
814 | ev_io_start (EV_A_ &pipeev); |
877 | ev_io_start (EV_A_ &pipeev); |
815 | ev_unref (EV_A); /* watcher should not keep loop alive */ |
878 | ev_unref (EV_A); /* watcher should not keep loop alive */ |
816 | } |
879 | } |
817 | } |
880 | } |
818 | |
881 | |
819 | void inline_size |
882 | void inline_size |
820 | evpipe_write (EV_P_ EV_ATOMIC_T *flag) |
883 | evpipe_write (EV_P_ EV_ATOMIC_T *flag) |
821 | { |
884 | { |
822 | if (!*flag) |
885 | if (!*flag) |
823 | { |
886 | { |
824 | int old_errno = errno; /* save errno becaue write might clobber it */ |
887 | int old_errno = errno; /* save errno because write might clobber it */ |
825 | |
888 | |
826 | *flag = 1; |
889 | *flag = 1; |
|
|
890 | |
|
|
891 | #if EV_USE_EVENTFD |
|
|
892 | if (evfd >= 0) |
|
|
893 | { |
|
|
894 | uint64_t counter = 1; |
|
|
895 | write (evfd, &counter, sizeof (uint64_t)); |
|
|
896 | } |
|
|
897 | else |
|
|
898 | #endif |
827 | write (evpipe [1], &old_errno, 1); |
899 | write (evpipe [1], &old_errno, 1); |
828 | |
900 | |
829 | errno = old_errno; |
901 | errno = old_errno; |
830 | } |
902 | } |
831 | } |
903 | } |
832 | |
904 | |
833 | static void |
905 | static void |
834 | pipecb (EV_P_ ev_io *iow, int revents) |
906 | pipecb (EV_P_ ev_io *iow, int revents) |
835 | { |
907 | { |
|
|
908 | #if EV_USE_EVENTFD |
|
|
909 | if (evfd >= 0) |
836 | { |
910 | { |
837 | int dummy; |
911 | uint64_t counter = 1; |
|
|
912 | read (evfd, &counter, sizeof (uint64_t)); |
|
|
913 | } |
|
|
914 | else |
|
|
915 | #endif |
|
|
916 | { |
|
|
917 | char dummy; |
838 | read (evpipe [0], &dummy, 1); |
918 | read (evpipe [0], &dummy, 1); |
839 | } |
919 | } |
840 | |
920 | |
841 | if (gotsig && ev_is_default_loop (EV_A)) |
921 | if (gotsig && ev_is_default_loop (EV_A)) |
842 | { |
922 | { |
843 | int signum; |
923 | int signum; |
844 | gotsig = 0; |
924 | gotsig = 0; |
… | |
… | |
865 | } |
945 | } |
866 | |
946 | |
867 | /*****************************************************************************/ |
947 | /*****************************************************************************/ |
868 | |
948 | |
869 | static void |
949 | static void |
870 | sighandler (int signum) |
950 | ev_sighandler (int signum) |
871 | { |
951 | { |
872 | #if EV_MULTIPLICITY |
952 | #if EV_MULTIPLICITY |
873 | struct ev_loop *loop = &default_loop_struct; |
953 | struct ev_loop *loop = &default_loop_struct; |
874 | #endif |
954 | #endif |
875 | |
955 | |
876 | #if _WIN32 |
956 | #if _WIN32 |
877 | signal (signum, sighandler); |
957 | signal (signum, ev_sighandler); |
878 | #endif |
958 | #endif |
879 | |
959 | |
880 | signals [signum - 1].gotsig = 1; |
960 | signals [signum - 1].gotsig = 1; |
881 | evpipe_write (EV_A_ &gotsig); |
961 | evpipe_write (EV_A_ &gotsig); |
882 | } |
962 | } |
… | |
… | |
912 | #ifndef WIFCONTINUED |
992 | #ifndef WIFCONTINUED |
913 | # define WIFCONTINUED(status) 0 |
993 | # define WIFCONTINUED(status) 0 |
914 | #endif |
994 | #endif |
915 | |
995 | |
916 | void inline_speed |
996 | void inline_speed |
917 | child_reap (EV_P_ ev_signal *sw, int chain, int pid, int status) |
997 | child_reap (EV_P_ int chain, int pid, int status) |
918 | { |
998 | { |
919 | ev_child *w; |
999 | ev_child *w; |
920 | int traced = WIFSTOPPED (status) || WIFCONTINUED (status); |
1000 | int traced = WIFSTOPPED (status) || WIFCONTINUED (status); |
921 | |
1001 | |
922 | for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next) |
1002 | for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next) |
923 | { |
1003 | { |
924 | if ((w->pid == pid || !w->pid) |
1004 | if ((w->pid == pid || !w->pid) |
925 | && (!traced || (w->flags & 1))) |
1005 | && (!traced || (w->flags & 1))) |
926 | { |
1006 | { |
927 | ev_set_priority (w, ev_priority (sw)); /* need to do it *now* */ |
1007 | ev_set_priority (w, EV_MAXPRI); /* need to do it *now*, this *must* be the same prio as the signal watcher itself */ |
928 | w->rpid = pid; |
1008 | w->rpid = pid; |
929 | w->rstatus = status; |
1009 | w->rstatus = status; |
930 | ev_feed_event (EV_A_ (W)w, EV_CHILD); |
1010 | ev_feed_event (EV_A_ (W)w, EV_CHILD); |
931 | } |
1011 | } |
932 | } |
1012 | } |
… | |
… | |
946 | if (!WCONTINUED |
1026 | if (!WCONTINUED |
947 | || errno != EINVAL |
1027 | || errno != EINVAL |
948 | || 0 >= (pid = waitpid (-1, &status, WNOHANG | WUNTRACED))) |
1028 | || 0 >= (pid = waitpid (-1, &status, WNOHANG | WUNTRACED))) |
949 | return; |
1029 | return; |
950 | |
1030 | |
951 | /* make sure we are called again until all childs have been reaped */ |
1031 | /* make sure we are called again until all children have been reaped */ |
952 | /* we need to do it this way so that the callback gets called before we continue */ |
1032 | /* we need to do it this way so that the callback gets called before we continue */ |
953 | ev_feed_event (EV_A_ (W)sw, EV_SIGNAL); |
1033 | ev_feed_event (EV_A_ (W)sw, EV_SIGNAL); |
954 | |
1034 | |
955 | child_reap (EV_A_ sw, pid, pid, status); |
1035 | child_reap (EV_A_ pid, pid, status); |
956 | if (EV_PID_HASHSIZE > 1) |
1036 | if (EV_PID_HASHSIZE > 1) |
957 | child_reap (EV_A_ sw, 0, pid, status); /* this might trigger a watcher twice, but feed_event catches that */ |
1037 | child_reap (EV_A_ 0, pid, status); /* this might trigger a watcher twice, but feed_event catches that */ |
958 | } |
1038 | } |
959 | |
1039 | |
960 | #endif |
1040 | #endif |
961 | |
1041 | |
962 | /*****************************************************************************/ |
1042 | /*****************************************************************************/ |
… | |
… | |
1105 | if (!(flags & EVFLAG_NOENV) |
1185 | if (!(flags & EVFLAG_NOENV) |
1106 | && !enable_secure () |
1186 | && !enable_secure () |
1107 | && getenv ("LIBEV_FLAGS")) |
1187 | && getenv ("LIBEV_FLAGS")) |
1108 | flags = atoi (getenv ("LIBEV_FLAGS")); |
1188 | flags = atoi (getenv ("LIBEV_FLAGS")); |
1109 | |
1189 | |
1110 | if (!(flags & 0x0000ffffUL)) |
1190 | if (!(flags & 0x0000ffffU)) |
1111 | flags |= ev_recommended_backends (); |
1191 | flags |= ev_recommended_backends (); |
1112 | |
1192 | |
1113 | #if EV_USE_PORT |
1193 | #if EV_USE_PORT |
1114 | if (!backend && (flags & EVBACKEND_PORT )) backend = port_init (EV_A_ flags); |
1194 | if (!backend && (flags & EVBACKEND_PORT )) backend = port_init (EV_A_ flags); |
1115 | #endif |
1195 | #endif |
… | |
… | |
1139 | if (ev_is_active (&pipeev)) |
1219 | if (ev_is_active (&pipeev)) |
1140 | { |
1220 | { |
1141 | ev_ref (EV_A); /* signal watcher */ |
1221 | ev_ref (EV_A); /* signal watcher */ |
1142 | ev_io_stop (EV_A_ &pipeev); |
1222 | ev_io_stop (EV_A_ &pipeev); |
1143 | |
1223 | |
1144 | close (evpipe [0]); evpipe [0] = 0; |
1224 | #if EV_USE_EVENTFD |
1145 | close (evpipe [1]); evpipe [1] = 0; |
1225 | if (evfd >= 0) |
|
|
1226 | close (evfd); |
|
|
1227 | #endif |
|
|
1228 | |
|
|
1229 | if (evpipe [0] >= 0) |
|
|
1230 | { |
|
|
1231 | close (evpipe [0]); |
|
|
1232 | close (evpipe [1]); |
|
|
1233 | } |
1146 | } |
1234 | } |
1147 | |
1235 | |
1148 | #if EV_USE_INOTIFY |
1236 | #if EV_USE_INOTIFY |
1149 | if (fs_fd >= 0) |
1237 | if (fs_fd >= 0) |
1150 | close (fs_fd); |
1238 | close (fs_fd); |
… | |
… | |
1195 | #endif |
1283 | #endif |
1196 | |
1284 | |
1197 | backend = 0; |
1285 | backend = 0; |
1198 | } |
1286 | } |
1199 | |
1287 | |
|
|
1288 | #if EV_USE_INOTIFY |
1200 | void inline_size infy_fork (EV_P); |
1289 | void inline_size infy_fork (EV_P); |
|
|
1290 | #endif |
1201 | |
1291 | |
1202 | void inline_size |
1292 | void inline_size |
1203 | loop_fork (EV_P) |
1293 | loop_fork (EV_P) |
1204 | { |
1294 | { |
1205 | #if EV_USE_PORT |
1295 | #if EV_USE_PORT |
… | |
… | |
1224 | gotasync = 1; |
1314 | gotasync = 1; |
1225 | #endif |
1315 | #endif |
1226 | |
1316 | |
1227 | ev_ref (EV_A); |
1317 | ev_ref (EV_A); |
1228 | ev_io_stop (EV_A_ &pipeev); |
1318 | ev_io_stop (EV_A_ &pipeev); |
|
|
1319 | |
|
|
1320 | #if EV_USE_EVENTFD |
|
|
1321 | if (evfd >= 0) |
|
|
1322 | close (evfd); |
|
|
1323 | #endif |
|
|
1324 | |
|
|
1325 | if (evpipe [0] >= 0) |
|
|
1326 | { |
1229 | close (evpipe [0]); |
1327 | close (evpipe [0]); |
1230 | close (evpipe [1]); |
1328 | close (evpipe [1]); |
|
|
1329 | } |
1231 | |
1330 | |
1232 | evpipe_init (EV_A); |
1331 | evpipe_init (EV_A); |
1233 | /* now iterate over everything, in case we missed something */ |
1332 | /* now iterate over everything, in case we missed something */ |
1234 | pipecb (EV_A_ &pipeev, EV_READ); |
1333 | pipecb (EV_A_ &pipeev, EV_READ); |
1235 | } |
1334 | } |
… | |
… | |
1542 | static int loop_done; |
1641 | static int loop_done; |
1543 | |
1642 | |
1544 | void |
1643 | void |
1545 | ev_loop (EV_P_ int flags) |
1644 | ev_loop (EV_P_ int flags) |
1546 | { |
1645 | { |
1547 | loop_done = flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK) |
1646 | loop_done = EVUNLOOP_CANCEL; |
1548 | ? EVUNLOOP_ONE |
|
|
1549 | : EVUNLOOP_CANCEL; |
|
|
1550 | |
1647 | |
1551 | call_pending (EV_A); /* in case we recurse, ensure ordering stays nice and clean */ |
1648 | call_pending (EV_A); /* in case we recurse, ensure ordering stays nice and clean */ |
1552 | |
1649 | |
1553 | do |
1650 | do |
1554 | { |
1651 | { |
… | |
… | |
1650 | /* queue check watchers, to be executed first */ |
1747 | /* queue check watchers, to be executed first */ |
1651 | if (expect_false (checkcnt)) |
1748 | if (expect_false (checkcnt)) |
1652 | queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); |
1749 | queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); |
1653 | |
1750 | |
1654 | call_pending (EV_A); |
1751 | call_pending (EV_A); |
1655 | |
|
|
1656 | } |
1752 | } |
1657 | while (expect_true (activecnt && !loop_done)); |
1753 | while (expect_true ( |
|
|
1754 | activecnt |
|
|
1755 | && !loop_done |
|
|
1756 | && !(flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK)) |
|
|
1757 | )); |
1658 | |
1758 | |
1659 | if (loop_done == EVUNLOOP_ONE) |
1759 | if (loop_done == EVUNLOOP_ONE) |
1660 | loop_done = EVUNLOOP_CANCEL; |
1760 | loop_done = EVUNLOOP_CANCEL; |
1661 | } |
1761 | } |
1662 | |
1762 | |
… | |
… | |
1930 | wlist_add (&signals [w->signum - 1].head, (WL)w); |
2030 | wlist_add (&signals [w->signum - 1].head, (WL)w); |
1931 | |
2031 | |
1932 | if (!((WL)w)->next) |
2032 | if (!((WL)w)->next) |
1933 | { |
2033 | { |
1934 | #if _WIN32 |
2034 | #if _WIN32 |
1935 | signal (w->signum, sighandler); |
2035 | signal (w->signum, ev_sighandler); |
1936 | #else |
2036 | #else |
1937 | struct sigaction sa; |
2037 | struct sigaction sa; |
1938 | sa.sa_handler = sighandler; |
2038 | sa.sa_handler = ev_sighandler; |
1939 | sigfillset (&sa.sa_mask); |
2039 | sigfillset (&sa.sa_mask); |
1940 | sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */ |
2040 | sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */ |
1941 | sigaction (w->signum, &sa, 0); |
2041 | sigaction (w->signum, &sa, 0); |
1942 | #endif |
2042 | #endif |
1943 | } |
2043 | } |