From 5d11f4f39ae9bb38f4eb9318068d605dd5d20e73 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 26 Apr 2013 11:57:40 -0400 Subject: [PATCH] Make the event_finalize* functions return an error code --- event.c | 15 +++++++++------ include/event2/event.h | 6 ++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/event.c b/event.c index 6b8c3c5b..4c56a3a0 100644 --- a/event.c +++ b/event.c @@ -2044,7 +2044,7 @@ event_debug_unassign(struct event *ev) } #define EVENT_FINALIZE_FREE_ 0x10000 -static void +static int event_finalize_nolock_(struct event_base *base, unsigned flags, struct event *ev, event_finalize_callback_fn cb) { uint8_t closure = (flags & EVENT_FINALIZE_FREE_) ? @@ -2055,29 +2055,32 @@ event_finalize_nolock_(struct event_base *base, unsigned flags, struct event *ev ev->ev_evcallback.evcb_cb_union.evcb_evfinalize = cb; event_active_nolock_(ev, EV_FINALIZE, 1); ev->ev_flags |= EVLIST_FINALIZING; + return 0; } -static void +static int event_finalize_impl_(unsigned flags, struct event *ev, event_finalize_callback_fn cb) { + int r; struct event_base *base = ev->ev_base; if (EVUTIL_FAILURE_CHECK(!base)) { event_warnx("%s: event has no event_base set.", __func__); - return; + return -1; } EVBASE_ACQUIRE_LOCK(base, th_base_lock); - event_finalize_nolock_(base, flags, ev, cb); + r = event_finalize_nolock_(base, flags, ev, cb); EVBASE_RELEASE_LOCK(base, th_base_lock); + return r; } -void +int event_finalize(unsigned flags, struct event *ev, event_finalize_callback_fn cb) { return event_finalize_impl_(flags, ev, cb); } -void +int event_free_finalize(unsigned flags, struct event *ev, event_finalize_callback_fn cb) { return event_finalize_impl_(flags|EVENT_FINALIZE_FREE_, ev, cb); diff --git a/include/event2/event.h b/include/event2/event.h index 4a63765c..b946b008 100644 --- a/include/event2/event.h +++ b/include/event2/event.h @@ -1046,10 +1046,12 @@ typedef void (*event_finalize_callback_fn)(struct event *, void *); A finalizer callback must not make events pending or active. It must not add events, activate events, or attempt to "resucitate" the event being finalized in any way. + + @return 0 on succes, -1 on failure. */ /**@{*/ -void event_finalize(unsigned, struct event *, event_finalize_callback_fn); -void event_free_finalize(unsigned, struct event *, event_finalize_callback_fn); +int event_finalize(unsigned, struct event *, event_finalize_callback_fn); +int event_free_finalize(unsigned, struct event *, event_finalize_callback_fn); /**@}*/ /** -- 2.40.0