]> granicus.if.org Git - libevent/commitdiff
Make the event_finalize* functions return an error code
authorNick Mathewson <nickm@torproject.org>
Fri, 26 Apr 2013 15:57:40 +0000 (11:57 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 26 Apr 2013 16:18:38 +0000 (12:18 -0400)
event.c
include/event2/event.h

diff --git a/event.c b/event.c
index 6b8c3c5b2a033782e4704f73f22dbe4ef031e7b0..4c56a3a0e1cf3d8bece460de82bf094f9388df23 100644 (file)
--- 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);
index 4a63765cefecf7e3eb15560dba5b89a632d88cb4..b946b00806bf85e2ab55b8e62477f0faddd7cdb3 100644 (file)
@@ -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);
 /**@}*/
 
 /**