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

Comparing libev/ev.c (file contents):
Revision 1.156 by root, Wed Nov 28 17:50:13 2007 UTC vs.
Revision 1.157 by root, Wed Nov 28 20:58:32 2007 UTC

589static void noinline 589static void noinline
590fd_rearm_all (EV_P) 590fd_rearm_all (EV_P)
591{ 591{
592 int fd; 592 int fd;
593 593
594 /* this should be highly optimised to not do anything but set a flag */
595 for (fd = 0; fd < anfdmax; ++fd) 594 for (fd = 0; fd < anfdmax; ++fd)
596 if (anfds [fd].events) 595 if (anfds [fd].events)
597 { 596 {
598 anfds [fd].events = 0; 597 anfds [fd].events = 0;
599 fd_change (EV_A_ fd); 598 fd_change (EV_A_ fd);
1270 ev_tstamp odiff = rtmn_diff; 1269 ev_tstamp odiff = rtmn_diff;
1271 1270
1272 /* loop a few times, before making important decisions. 1271 /* loop a few times, before making important decisions.
1273 * on the choice of "4": one iteration isn't enough, 1272 * on the choice of "4": one iteration isn't enough,
1274 * in case we get preempted during the calls to 1273 * in case we get preempted during the calls to
1275 * ev_time and get_clock. a second call is almost guarenteed 1274 * ev_time and get_clock. a second call is almost guaranteed
1276 * to succeed in that case, though. and looping a few more times 1275 * to succeed in that case, though. and looping a few more times
1277 * doesn't hurt either as we only do this on time-jumps or 1276 * doesn't hurt either as we only do this on time-jumps or
1278 * in the unlikely event of getting preempted here. 1277 * in the unlikely event of having been preempted here.
1279 */ 1278 */
1280 for (i = 4; --i; ) 1279 for (i = 4; --i; )
1281 { 1280 {
1282 rtmn_diff = ev_rt_now - mn_now; 1281 rtmn_diff = ev_rt_now - mn_now;
1283 1282
1305 { 1304 {
1306#if EV_PERIODIC_ENABLE 1305#if EV_PERIODIC_ENABLE
1307 periodics_reschedule (EV_A); 1306 periodics_reschedule (EV_A);
1308#endif 1307#endif
1309 1308
1310 /* adjust timers. this is easy, as the offset is the same for all */ 1309 /* adjust timers. this is easy, as the offset is the same for all of them */
1311 for (i = 0; i < timercnt; ++i) 1310 for (i = 0; i < timercnt; ++i)
1312 ((WT)timers [i])->at += ev_rt_now - mn_now; 1311 ((WT)timers [i])->at += ev_rt_now - mn_now;
1313 } 1312 }
1314 1313
1315 mn_now = ev_rt_now; 1314 mn_now = ev_rt_now;
1337 ? EVUNLOOP_ONE 1336 ? EVUNLOOP_ONE
1338 : EVUNLOOP_CANCEL; 1337 : EVUNLOOP_CANCEL;
1339 1338
1340 while (activecnt) 1339 while (activecnt)
1341 { 1340 {
1342 /* we might have forked, so reify kernel state if necessary */
1343 #if EV_FORK_ENABLE 1341#if EV_FORK_ENABLE
1342 /* we might have forked, so queue fork handlers */
1344 if (expect_false (postfork)) 1343 if (expect_false (postfork))
1345 if (forkcnt) 1344 if (forkcnt)
1346 { 1345 {
1347 queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); 1346 queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK);
1348 call_pending (EV_A); 1347 call_pending (EV_A);
1349 } 1348 }
1350 #endif 1349#endif
1351 1350
1352 /* queue check watchers (and execute them) */ 1351 /* queue check watchers (and execute them) */
1353 if (expect_false (preparecnt)) 1352 if (expect_false (preparecnt))
1354 { 1353 {
1355 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); 1354 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE);
1363 /* update fd-related kernel structures */ 1362 /* update fd-related kernel structures */
1364 fd_reify (EV_A); 1363 fd_reify (EV_A);
1365 1364
1366 /* calculate blocking time */ 1365 /* calculate blocking time */
1367 { 1366 {
1368 double block; 1367 ev_tstamp block;
1369 1368
1370 if (flags & EVLOOP_NONBLOCK || idlecnt) 1369 if (flags & EVLOOP_NONBLOCK || idlecnt)
1371 block = 0.; /* do not block at all */ 1370 block = 0.; /* do not block at all */
1372 else 1371 else
1373 { 1372 {
1718# endif 1717# endif
1719 1718
1720#define DEF_STAT_INTERVAL 5.0074891 1719#define DEF_STAT_INTERVAL 5.0074891
1721#define MIN_STAT_INTERVAL 0.1074891 1720#define MIN_STAT_INTERVAL 0.1074891
1722 1721
1723void noinline stat_timer_cb (EV_P_ ev_timer *w_, int revents); 1722static void noinline stat_timer_cb (EV_P_ ev_timer *w_, int revents);
1724 1723
1725#if EV_USE_INOTIFY 1724#if EV_USE_INOTIFY
1726# define EV_INOTIFY_BUFSIZE 8192 1725# define EV_INOTIFY_BUFSIZE 8192
1727 1726
1728static void noinline 1727static void noinline
1879 w->attr.st_nlink = 0; 1878 w->attr.st_nlink = 0;
1880 else if (!w->attr.st_nlink) 1879 else if (!w->attr.st_nlink)
1881 w->attr.st_nlink = 1; 1880 w->attr.st_nlink = 1;
1882} 1881}
1883 1882
1884void noinline 1883static void noinline
1885stat_timer_cb (EV_P_ ev_timer *w_, int revents) 1884stat_timer_cb (EV_P_ ev_timer *w_, int revents)
1886{ 1885{
1887 ev_stat *w = (ev_stat *)(((char *)w_) - offsetof (ev_stat, timer)); 1886 ev_stat *w = (ev_stat *)(((char *)w_) - offsetof (ev_stat, timer));
1888 1887
1889 /* we copy this here each the time so that */ 1888 /* we copy this here each the time so that */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines