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

Comparing libev/ev.c (file contents):
Revision 1.198 by root, Sun Dec 23 04:45:51 2007 UTC vs.
Revision 1.206 by root, Fri Jan 25 15:45:08 2008 UTC

2 * libev event processing core, watcher management 2 * libev event processing core, watcher management
3 * 3 *
4 * Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de> 4 * Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * modification, are permitted provided that the following conditions are 8 * tion, are permitted provided that the following conditions are met:
9 * met: 9 *
10 * 1. Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
19 * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
21 * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
25 * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
26 * OF THE POSSIBILITY OF SUCH DAMAGE.
10 * 27 *
11 * * Redistributions of source code must retain the above copyright 28 * Alternatively, the contents of this file may be used under the terms of
12 * notice, this list of conditions and the following disclaimer. 29 * the GNU General Public License ("GPL") version 2 or any later version,
13 * 30 * in which case the provisions of the GPL are applicable instead of
14 * * Redistributions in binary form must reproduce the above 31 * the above. If you wish to allow the use of your version of this file
15 * copyright notice, this list of conditions and the following 32 * only under the terms of the GPL and not to allow others to use your
16 * disclaimer in the documentation and/or other materials provided 33 * version of this file under the BSD license, indicate your decision
17 * with the distribution. 34 * by deleting the provisions above and replace them with the notice
18 * 35 * and other provisions required by the GPL. If you do not delete the
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 36 * provisions above, a recipient may use your version of this file under
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 37 * either the BSD or the GPL.
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 38 */
31 39
32#ifdef __cplusplus 40#ifdef __cplusplus
33extern "C" { 41extern "C" {
34#endif 42#endif
592 600
593#if EV_SELECT_IS_WINSOCKET 601#if EV_SELECT_IS_WINSOCKET
594 if (events) 602 if (events)
595 { 603 {
596 unsigned long argp; 604 unsigned long argp;
605 #ifdef EV_FD_TO_WIN32_HANDLE
606 anfd->handle = EV_FD_TO_WIN32_HANDLE (fd);
607 #else
597 anfd->handle = _get_osfhandle (fd); 608 anfd->handle = _get_osfhandle (fd);
609 #endif
598 assert (("libev only supports socket fds in this configuration", ioctlsocket (anfd->handle, FIONREAD, &argp) == 0)); 610 assert (("libev only supports socket fds in this configuration", ioctlsocket (anfd->handle, FIONREAD, &argp) == 0));
599 } 611 }
600#endif 612#endif
601 613
602 { 614 {
855 867
856#ifndef _WIN32 868#ifndef _WIN32
857 869
858static ev_signal childev; 870static ev_signal childev;
859 871
872#ifndef WIFCONTINUED
873# define WIFCONTINUED(status) 0
874#endif
875
860void inline_speed 876void inline_speed
861child_reap (EV_P_ ev_signal *sw, int chain, int pid, int status) 877child_reap (EV_P_ ev_signal *sw, int chain, int pid, int status)
862{ 878{
863 ev_child *w; 879 ev_child *w;
880 int traced = WIFSTOPPED (status) || WIFCONTINUED (status);
864 881
865 for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next) 882 for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next)
883 {
866 if (w->pid == pid || !w->pid) 884 if ((w->pid == pid || !w->pid)
885 && (!traced || (w->flags & 1)))
867 { 886 {
868 ev_set_priority (w, ev_priority (sw)); /* need to do it *now* */ 887 ev_set_priority (w, ev_priority (sw)); /* need to do it *now* */
869 w->rpid = pid; 888 w->rpid = pid;
870 w->rstatus = status; 889 w->rstatus = status;
871 ev_feed_event (EV_A_ (W)w, EV_CHILD); 890 ev_feed_event (EV_A_ (W)w, EV_CHILD);
872 } 891 }
892 }
873} 893}
874 894
875#ifndef WCONTINUED 895#ifndef WCONTINUED
876# define WCONTINUED 0 896# define WCONTINUED 0
877#endif 897#endif
1154 1174
1155 while (pipe (sigpipe)) 1175 while (pipe (sigpipe))
1156 syserr ("(libev) error creating pipe"); 1176 syserr ("(libev) error creating pipe");
1157 1177
1158 siginit (EV_A); 1178 siginit (EV_A);
1179 sigcb (EV_A_ &sigev, EV_READ);
1159 } 1180 }
1160 1181
1161 postfork = 0; 1182 postfork = 0;
1162} 1183}
1163 1184
1185} 1206}
1186 1207
1187void 1208void
1188ev_loop_fork (EV_P) 1209ev_loop_fork (EV_P)
1189{ 1210{
1190 postfork = 1; 1211 postfork = 1; /* must be in line with ev_default_fork */
1191} 1212}
1192 1213
1193#endif 1214#endif
1194 1215
1195#if EV_MULTIPLICITY 1216#if EV_MULTIPLICITY
1259#if EV_MULTIPLICITY 1280#if EV_MULTIPLICITY
1260 struct ev_loop *loop = ev_default_loop_ptr; 1281 struct ev_loop *loop = ev_default_loop_ptr;
1261#endif 1282#endif
1262 1283
1263 if (backend) 1284 if (backend)
1264 postfork = 1; 1285 postfork = 1; /* must be in line with ev_loop_fork */
1265} 1286}
1266 1287
1267/*****************************************************************************/ 1288/*****************************************************************************/
1268 1289
1269void 1290void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines