static inline int event_add_internal(struct event *ev,
const struct timeval *tv);
static inline int event_del_internal(struct event *ev);
-static inline void event_active_internal(struct event *ev, int res,short count);
static void event_queue_insert(struct event_base *, struct event *, int);
static void event_queue_remove(struct event_base *, struct event *, int);
static void timeout_process(struct event_base *);
static void timeout_correct(struct event_base *, struct timeval *);
-static void event_signal_closure(struct event_base *, struct event *ev);
-static void event_persist_closure(struct event_base *, struct event *ev);
+static inline void event_signal_closure(struct event_base *, struct event *ev);
+static inline void event_persist_closure(struct event_base *, struct event *ev);
static int evthread_notify_base(struct event_base *base);
{
int i, n_deleted=0;
struct event *ev;
+ /* XXXX grab the lock? If there is contention when one thread frees
+ * the base, then the contending thread will be very sad soon. */
if (base == NULL && current_base)
base = current_base;
mm_free(base);
}
-/* reinitialized the event base after a fork */
+/* reinitialize the event base after a fork */
int
event_reinit(struct event_base *base)
{
+ /* XXXX Do we need to grab a lock here? */
const struct eventop *evsel = base->evsel;
int res = 0;
struct event *ev;
return (base->event_count > 0);
}
-static void
+static inline void
event_persist_closure(struct event_base *base, struct event *ev)
{
/* reschedule the persistent event if we have a timeout */
if (ev->ev_io_timeout.tv_sec || ev->ev_io_timeout.tv_usec)
- event_add(ev, &ev->ev_io_timeout);
+ event_add_internal(ev, &ev->ev_io_timeout);
(*ev->ev_callback)((int)ev->ev_fd, ev->ev_res, ev->ev_arg);
}
-static void
+static inline void
event_signal_closure(struct event_base *base, struct event *ev)
{
short ncalls;
{
EVBASE_ACQUIRE_LOCK(ev->ev_base, EVTHREAD_WRITE, th_base_lock);
- event_active_internal(ev, res, ncalls);
+ event_active_nolock(ev, res, ncalls);
EVBASE_RELEASE_LOCK(ev->ev_base, EVTHREAD_WRITE, th_base_lock);
}
-static inline void
-event_active_internal(struct event *ev, int res, short ncalls)
+void
+event_active_nolock(struct event *ev, int res, short ncalls)
{
struct event_base *base;
event_debug(("timeout_process: call %p",
ev->ev_callback));
- event_active_internal(ev, EV_TIMEOUT, 1);
+ event_active_nolock(ev, EV_TIMEOUT, 1);
}
}
void (*cb)(evutil_socket_t, short, void *) = evthread_notify_drain_default;
int (*notify)(struct event_base *) = evthread_notify_base_default;
+ /* XXXX grab the lock here? */
if (!base)
return -1;
EVUTIL_ASSERT(ctx);
TAILQ_FOREACH(ev, &ctx->events, ev_io_next) {
if (ev->ev_events & events)
- event_active(ev, ev->ev_events & events, 1);
+ event_active_nolock(ev, ev->ev_events & events, 1);
}
}
GET_SIGNAL_SLOT(ctx, map, sig, evmap_signal);
TAILQ_FOREACH(ev, &ctx->events, ev_signal_next)
- event_active(ev, EV_SIGNAL, ncalls);
+ event_active_nolock(ev, EV_SIGNAL, ncalls);
}
void *