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

Comparing libev/ev.c (file contents):
Revision 1.157 by root, Wed Nov 28 20:58:32 2007 UTC vs.
Revision 1.161 by root, Sat Dec 1 23:43:45 2007 UTC

904 ev_rt_now = ev_time (); 904 ev_rt_now = ev_time ();
905 mn_now = get_clock (); 905 mn_now = get_clock ();
906 now_floor = mn_now; 906 now_floor = mn_now;
907 rtmn_diff = ev_rt_now - mn_now; 907 rtmn_diff = ev_rt_now - mn_now;
908 908
909 /* pid check not overridable via env */
910#ifndef _WIN32
911 if (flags & EVFLAG_FORKCHECK)
912 curpid = getpid ();
913#endif
914
909 if (!(flags & EVFLAG_NOENV) 915 if (!(flags & EVFLAG_NOENV)
910 && !enable_secure () 916 && !enable_secure ()
911 && getenv ("LIBEV_FLAGS")) 917 && getenv ("LIBEV_FLAGS"))
912 flags = atoi (getenv ("LIBEV_FLAGS")); 918 flags = atoi (getenv ("LIBEV_FLAGS"));
913 919
1334{ 1340{
1335 loop_done = flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK) 1341 loop_done = flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK)
1336 ? EVUNLOOP_ONE 1342 ? EVUNLOOP_ONE
1337 : EVUNLOOP_CANCEL; 1343 : EVUNLOOP_CANCEL;
1338 1344
1339 while (activecnt) 1345 call_pending (EV_A); /* in case we recurse, ensure ordering stays nice and clean */
1346
1347 do
1340 { 1348 {
1349#ifndef _WIN32
1350 if (expect_false (curpid)) /* penalise the forking check even more */
1351 if (expect_false (getpid () != curpid))
1352 {
1353 curpid = getpid ();
1354 postfork = 1;
1355 }
1356#endif
1357
1341#if EV_FORK_ENABLE 1358#if EV_FORK_ENABLE
1342 /* we might have forked, so queue fork handlers */ 1359 /* we might have forked, so queue fork handlers */
1343 if (expect_false (postfork)) 1360 if (expect_false (postfork))
1344 if (forkcnt) 1361 if (forkcnt)
1345 { 1362 {
1353 { 1370 {
1354 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); 1371 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE);
1355 call_pending (EV_A); 1372 call_pending (EV_A);
1356 } 1373 }
1357 1374
1375 if (expect_false (!activecnt))
1376 break;
1377
1358 /* we might have forked, so reify kernel state if necessary */ 1378 /* we might have forked, so reify kernel state if necessary */
1359 if (expect_false (postfork)) 1379 if (expect_false (postfork))
1360 loop_fork (EV_A); 1380 loop_fork (EV_A);
1361 1381
1362 /* update fd-related kernel structures */ 1382 /* update fd-related kernel structures */
1364 1384
1365 /* calculate blocking time */ 1385 /* calculate blocking time */
1366 { 1386 {
1367 ev_tstamp block; 1387 ev_tstamp block;
1368 1388
1369 if (flags & EVLOOP_NONBLOCK || idlecnt) 1389 if (expect_false (flags & EVLOOP_NONBLOCK || idlecnt || !activecnt))
1370 block = 0.; /* do not block at all */ 1390 block = 0.; /* do not block at all */
1371 else 1391 else
1372 { 1392 {
1373 /* update time to cancel out callback processing overhead */ 1393 /* update time to cancel out callback processing overhead */
1374#if EV_USE_MONOTONIC 1394#if EV_USE_MONOTONIC
1420 if (expect_false (checkcnt)) 1440 if (expect_false (checkcnt))
1421 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); 1441 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK);
1422 1442
1423 call_pending (EV_A); 1443 call_pending (EV_A);
1424 1444
1425 if (expect_false (loop_done))
1426 break;
1427 } 1445 }
1446 while (expect_true (activecnt && !loop_done));
1428 1447
1429 if (loop_done == EVUNLOOP_ONE) 1448 if (loop_done == EVUNLOOP_ONE)
1430 loop_done = EVUNLOOP_CANCEL; 1449 loop_done = EVUNLOOP_CANCEL;
1431} 1450}
1432 1451

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines