mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Detect events with no ev_base; warn instead of crashing
This commit is contained in:
parent
743f866539
commit
f1074b776a
15
event.c
15
event.c
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user