Detect events with no ev_base; warn instead of crashing

This commit is contained in:
Nick Mathewson 2010-08-23 12:01:45 -04:00
parent 743f866539
commit f1074b776a

15
event.c
View File

@ -1818,6 +1818,11 @@ event_add(struct event *ev, const struct timeval *tv)
{
int res;
if (EVUTIL_FAILURE_CHECK(!ev->ev_base)) {
event_warnx("%s: event has no event_base set.", __func__);
return -1;
}
EVBASE_ACQUIRE_LOCK(ev->ev_base, th_base_lock);
res = event_add_internal(ev, tv, 0);
@ -2030,6 +2035,11 @@ event_del(struct event *ev)
{
int res;
if (EVUTIL_FAILURE_CHECK(!ev->ev_base)) {
event_warnx("%s: event has no event_base set.", __func__);
return -1;
}
EVBASE_ACQUIRE_LOCK(ev->ev_base, th_base_lock);
res = event_del_internal(ev);
@ -2117,6 +2127,11 @@ event_del_internal(struct event *ev)
void
event_active(struct event *ev, int res, short ncalls)
{
if (EVUTIL_FAILURE_CHECK(!ev->ev_base)) {
event_warnx("%s: event has no event_base set.", __func__);
return;
}
EVBASE_ACQUIRE_LOCK(ev->ev_base, th_base_lock);
_event_debug_assert_is_setup(ev);