void event_queue_insert(struct event *, int);
void event_queue_remove(struct event *, int);
int event_haveevents(void);
-void timeout_insert(struct event *);
static void event_process_active(void);
return (-1);
else if (timercmp(&a->ev_timeout, &b->ev_timeout, >))
return (1);
+ if (a < b)
+ return (-1);
+ if (a > b)
+ return (1);
return (0);
}
}
}
-void
-timeout_insert(struct event *ev)
-{
- struct event *tmp;
-
- tmp = RB_FIND(event_tree, &timetree, ev);
-
- if (tmp != NULL) {
- struct timeval tv;
- struct timeval add = {0,1};
-
- /* Find unique time */
- tv = ev->ev_timeout;
- do {
- timeradd(&tv, &add, &tv);
- tmp = RB_NEXT(event_tree, &timetree, tmp);
- } while (tmp != NULL && timercmp(&tmp->ev_timeout, &tv, ==));
-
- ev->ev_timeout = tv;
- }
-
- tmp = RB_INSERT(event_tree, &timetree, ev);
- assert(tmp == NULL);
-}
-
void
event_queue_remove(struct event *ev, int queue)
{
case EVLIST_SIGNAL:
TAILQ_INSERT_TAIL(&signalqueue, ev, ev_signal_next);
break;
- case EVLIST_TIMEOUT:
- timeout_insert(ev);
+ case EVLIST_TIMEOUT: {
+ struct event *tmp = RB_INSERT(event_tree, &timetree, ev);
+ assert(tmp == NULL);
break;
+ }
case EVLIST_INSERTED:
TAILQ_INSERT_TAIL(&eventqueue, ev, ev_next);
break;