From fbe9562600fa8735c078401aa604b49a5426b0e2 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 4 Nov 2007 22:03:17 +0000 Subject: bugfixes --- ev.c | 37 +++++++++++++++++++------------------ ev_epoll.c | 2 +- event.c | 8 ++------ 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/ev.c b/ev.c index ed0be41..5756bb7 100644 --- a/ev.c +++ b/ev.c @@ -524,9 +524,9 @@ child_reap (EV_P_ struct ev_signal *sw, int chain, int pid, int status) for (w = (struct ev_child *)childs [chain & (PID_HASHSIZE - 1)]; w; w = (struct ev_child *)((WL)w)->next) if (w->pid == pid || !w->pid) { - w->priority = sw->priority; /* need to do it *now* */ - w->rpid = pid; - w->rstatus = status; + ev_priority (w) = ev_priority (sw); /* need to do it *now* */ + w->rpid = pid; + w->rstatus = status; event (EV_A_ (W)w, EV_CHILD); } } @@ -798,7 +798,8 @@ call_pending (EV_P) if (p->w) { p->w->pending = 0; - p->w->cb (EV_A_ p->w, p->events); + + (*(void (**)(EV_P_ W, int))&p->w->cb) (EV_A_ p->w, p->events); } } } @@ -806,7 +807,7 @@ call_pending (EV_P) static void timers_reify (EV_P) { - while (timercnt && timers [0]->at <= mn_now) + while (timercnt && ((WT)timers [0])->at <= mn_now) { struct ev_timer *w = timers [0]; @@ -816,7 +817,7 @@ timers_reify (EV_P) if (w->repeat) { assert (("negative ev_timer repeat value found while processing timers", w->repeat > 0.)); - w->at = mn_now + w->repeat; + ((WT)w)->at = mn_now + w->repeat; downheap ((WT *)timers, timercnt, 0); } else @@ -829,7 +830,7 @@ timers_reify (EV_P) static void periodics_reify (EV_P) { - while (periodiccnt && periodics [0]->at <= rt_now) + while (periodiccnt && ((WT)periodics [0])->at <= rt_now) { struct ev_periodic *w = periodics [0]; @@ -838,8 +839,8 @@ periodics_reify (EV_P) /* first reschedule or stop timer */ if (w->interval) { - w->at += floor ((rt_now - w->at) / w->interval + 1.) * w->interval; - assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", w->at > rt_now)); + ((WT)w)->at += floor ((rt_now - ((WT)w)->at) / w->interval + 1.) * w->interval; + assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ((WT)w)->at > rt_now)); downheap ((WT *)periodics, periodiccnt, 0); } else @@ -861,7 +862,7 @@ periodics_reschedule (EV_P) if (w->interval) { - ev_tstamp diff = ceil ((rt_now - w->at) / w->interval) * w->interval; + ev_tstamp diff = ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval; if (fabs (diff) >= 1e-4) { @@ -932,7 +933,7 @@ time_update (EV_P) /* adjust timers. this is easy, as the offset is the same for all */ for (i = 0; i < timercnt; ++i) - timers [i]->at += rt_now - mn_now; + ((WT)timers [i])->at += rt_now - mn_now; } mn_now = rt_now; @@ -993,13 +994,13 @@ ev_loop (EV_P_ int flags) if (timercnt) { - ev_tstamp to = timers [0]->at - mn_now + method_fudge; + ev_tstamp to = ((WT)timers [0])->at - mn_now + method_fudge; if (block > to) block = to; } if (periodiccnt) { - ev_tstamp to = periodics [0]->at - rt_now + method_fudge; + ev_tstamp to = ((WT)periodics [0])->at - rt_now + method_fudge; if (block > to) block = to; } @@ -1126,7 +1127,7 @@ ev_timer_start (EV_P_ struct ev_timer *w) if (ev_is_active (w)) return; - w->at += mn_now; + ((WT)w)->at += mn_now; assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); @@ -1153,7 +1154,7 @@ ev_timer_stop (EV_P_ struct ev_timer *w) downheap ((WT *)timers, timercnt, ((W)w)->active - 1); } - w->at = w->repeat; + ((WT)w)->at = w->repeat; ev_stop (EV_A_ (W)w); } @@ -1165,7 +1166,7 @@ ev_timer_again (EV_P_ struct ev_timer *w) { if (w->repeat) { - w->at = mn_now + w->repeat; + ((WT)w)->at = mn_now + w->repeat; downheap ((WT *)timers, timercnt, ((W)w)->active - 1); } else @@ -1185,7 +1186,7 @@ ev_periodic_start (EV_P_ struct ev_periodic *w) /* this formula differs from the one in periodic_reify because we do not always round up */ if (w->interval) - w->at += ceil ((rt_now - w->at) / w->interval) * w->interval; + ((WT)w)->at += ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval; ev_start (EV_A_ (W)w, ++periodiccnt); array_needsize (periodics, periodicmax, periodiccnt, ); @@ -1298,7 +1299,7 @@ ev_signal_start (EV_P_ struct ev_signal *w) array_needsize (signals, signalmax, w->signum, signals_init); wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); - if (!w->next) + if (!((WL)w)->next) { struct sigaction sa; sa.sa_handler = sighandler; diff --git a/ev_epoll.c b/ev_epoll.c index bdd746b..ffb1f05 100644 --- a/ev_epoll.c +++ b/ev_epoll.c @@ -42,7 +42,7 @@ epoll_modify (EV_P_ int fd, int oev, int nev) (nev & EV_READ ? EPOLLIN : 0) | (nev & EV_WRITE ? EPOLLOUT : 0); - if (!epoll_ctl (epoll_fd, mode, fd, &ev)) + if (epoll_ctl (epoll_fd, mode, fd, &ev)) fd_kill (EV_A_ fd); } diff --git a/event.c b/event.c index b73d16b..b34774c 100644 --- a/event.c +++ b/event.c @@ -167,7 +167,6 @@ x_cb_to (EV_P_ struct ev_timer *w, int revents) void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg) { - printf ("event set %p\n", ev);//D if (events & EV_SIGNAL) ev_watcher_init (&ev->iosig.sig, x_cb_sig); else @@ -191,7 +190,6 @@ int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, int event_add (struct event *ev, struct timeval *tv) { - printf ("event add %p %p\n", ev, &ev->to);//D dLOOPev; /* disable all watchers */ @@ -219,7 +217,6 @@ int event_add (struct event *ev, struct timeval *tv) int event_del (struct event *ev) { - printf ("event del %p\n", ev);//D dLOOPev; if (ev->ev_events & EV_SIGNAL) @@ -228,14 +225,13 @@ int event_del (struct event *ev) if (ev_is_active (&ev->iosig.sig)) ev_signal_stop (EV_A_ &ev->iosig.sig); } - else + else if (ev->ev_events & (EV_READ | EV_WRITE)) { /* io */ if (ev_is_active (&ev->iosig.io)) ev_io_stop (EV_A_ &ev->iosig.io); } - printf ("to %p %d\n", &ev->to, ev->to.active);//D if (ev_is_active (&ev->to)) ev_timer_stop (EV_A_ &ev->to); @@ -254,7 +250,7 @@ int event_pending (struct event *ev, short events, struct timeval *tv) if (ev_is_active (&ev->iosig.sig) || ev_is_pending (&ev->iosig.sig)) revents |= EV_SIGNAL; } - else + else if (ev->ev_events & (EV_READ | EV_WRITE)) { /* io */ if (ev_is_active (&ev->iosig.io) || ev_is_pending (&ev->iosig.io)) -- cgit v1.2.3