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

Comparing libev/ev.c (file contents):
Revision 1.77 by root, Thu Nov 8 00:44:17 2007 UTC vs.
Revision 1.78 by root, Thu Nov 8 21:08:56 2007 UTC

316 316
317 ++base; 317 ++base;
318 } 318 }
319} 319}
320 320
321static void 321void
322event (EV_P_ W w, int events) 322ev_feed_event (EV_P_ void *w, int revents)
323{ 323{
324 W w_ = (W)w;
325
324 if (w->pending) 326 if (w_->pending)
325 { 327 {
326 pendings [ABSPRI (w)][w->pending - 1].events |= events; 328 pendings [ABSPRI (w_)][w_->pending - 1].events |= revents;
327 return; 329 return;
328 } 330 }
329 331
330 w->pending = ++pendingcnt [ABSPRI (w)]; 332 w_->pending = ++pendingcnt [ABSPRI (w_)];
331 array_needsize (ANPENDING, pendings [ABSPRI (w)], pendingmax [ABSPRI (w)], pendingcnt [ABSPRI (w)], (void)); 333 array_needsize (ANPENDING, pendings [ABSPRI (w_)], pendingmax [ABSPRI (w_)], pendingcnt [ABSPRI (w_)], (void));
332 pendings [ABSPRI (w)][w->pending - 1].w = w; 334 pendings [ABSPRI (w_)][w_->pending - 1].w = w_;
333 pendings [ABSPRI (w)][w->pending - 1].events = events; 335 pendings [ABSPRI (w_)][w_->pending - 1].events = revents;
334} 336}
335 337
336static void 338static void
337queue_events (EV_P_ W *events, int eventcnt, int type) 339queue_events (EV_P_ W *events, int eventcnt, int type)
338{ 340{
339 int i; 341 int i;
340 342
341 for (i = 0; i < eventcnt; ++i) 343 for (i = 0; i < eventcnt; ++i)
342 event (EV_A_ events [i], type); 344 ev_feed_event (EV_A_ events [i], type);
343} 345}
344 346
345static void 347static void
346fd_event (EV_P_ int fd, int events) 348fd_event (EV_P_ int fd, int events)
347{ 349{
351 for (w = (struct ev_io *)anfd->head; w; w = (struct ev_io *)((WL)w)->next) 353 for (w = (struct ev_io *)anfd->head; w; w = (struct ev_io *)((WL)w)->next)
352 { 354 {
353 int ev = w->events & events; 355 int ev = w->events & events;
354 356
355 if (ev) 357 if (ev)
356 event (EV_A_ (W)w, ev); 358 ev_feed_event (EV_A_ (W)w, ev);
357 } 359 }
358} 360}
359 361
360/*****************************************************************************/ 362/*****************************************************************************/
361 363
403 struct ev_io *w; 405 struct ev_io *w;
404 406
405 while ((w = (struct ev_io *)anfds [fd].head)) 407 while ((w = (struct ev_io *)anfds [fd].head))
406 { 408 {
407 ev_io_stop (EV_A_ w); 409 ev_io_stop (EV_A_ w);
408 event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE); 410 ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE);
409 } 411 }
410} 412}
411 413
412static int 414static int
413fd_valid (int fd) 415fd_valid (int fd)
569 if (signals [signum].gotsig) 571 if (signals [signum].gotsig)
570 { 572 {
571 signals [signum].gotsig = 0; 573 signals [signum].gotsig = 0;
572 574
573 for (w = signals [signum].head; w; w = w->next) 575 for (w = signals [signum].head; w; w = w->next)
574 event (EV_A_ (W)w, EV_SIGNAL); 576 ev_feed_event (EV_A_ (W)w, EV_SIGNAL);
575 } 577 }
576} 578}
577 579
578static void 580static void
579siginit (EV_P) 581siginit (EV_P)
613 if (w->pid == pid || !w->pid) 615 if (w->pid == pid || !w->pid)
614 { 616 {
615 ev_priority (w) = ev_priority (sw); /* need to do it *now* */ 617 ev_priority (w) = ev_priority (sw); /* need to do it *now* */
616 w->rpid = pid; 618 w->rpid = pid;
617 w->rstatus = status; 619 w->rstatus = status;
618 event (EV_A_ (W)w, EV_CHILD); 620 ev_feed_event (EV_A_ (W)w, EV_CHILD);
619 } 621 }
620} 622}
621 623
622static void 624static void
623childcb (EV_P_ struct ev_signal *sw, int revents) 625childcb (EV_P_ struct ev_signal *sw, int revents)
625 int pid, status; 627 int pid, status;
626 628
627 if (0 < (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED))) 629 if (0 < (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED)))
628 { 630 {
629 /* make sure we are called again until all childs have been reaped */ 631 /* make sure we are called again until all childs have been reaped */
630 event (EV_A_ (W)sw, EV_SIGNAL); 632 ev_feed_event (EV_A_ (W)sw, EV_SIGNAL);
631 633
632 child_reap (EV_A_ sw, pid, pid, status); 634 child_reap (EV_A_ sw, pid, pid, status);
633 child_reap (EV_A_ sw, 0, pid, status); /* this might trigger a watcher twice, but event catches that */ 635 child_reap (EV_A_ sw, 0, pid, status); /* this might trigger a watcher twice, but event catches that */
634 } 636 }
635} 637}
946 downheap ((WT *)timers, timercnt, 0); 948 downheap ((WT *)timers, timercnt, 0);
947 } 949 }
948 else 950 else
949 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */ 951 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */
950 952
951 event (EV_A_ (W)w, EV_TIMEOUT); 953 ev_feed_event (EV_A_ (W)w, EV_TIMEOUT);
952 } 954 }
953} 955}
954 956
955static void 957static void
956periodics_reify (EV_P) 958periodics_reify (EV_P)
976 downheap ((WT *)periodics, periodiccnt, 0); 978 downheap ((WT *)periodics, periodiccnt, 0);
977 } 979 }
978 else 980 else
979 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */ 981 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */
980 982
981 event (EV_A_ (W)w, EV_PERIODIC); 983 ev_feed_event (EV_A_ (W)w, EV_PERIODIC);
982 } 984 }
983} 985}
984 986
985static void 987static void
986periodics_reschedule (EV_P) 988periodics_reschedule (EV_P)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines