]> granicus.if.org Git - libevent/commitdiff
Make event_pending() threadsafe.
authorSimon Liu <simohayha.bobo@gmail.com>
Thu, 14 Jun 2012 17:01:05 +0000 (01:01 +0800)
committerNick Mathewson <nickm@torproject.org>
Thu, 14 Jun 2012 17:38:33 +0000 (13:38 -0400)
(Commit message by Nick)

event.c

diff --git a/event.c b/event.c
index 325f005b407e1d48ad01323977d8dcb0d0491075..09df46b032d416a2f3d844ae70e83e280dcaff28 100644 (file)
--- a/event.c
+++ b/event.c
@@ -1846,6 +1846,7 @@ event_pending(const struct event *ev, short event, struct timeval *tv)
 {
        int flags = 0;
 
+       EVBASE_ACQUIRE_LOCK(ev->ev_base, th_base_lock);
        _event_debug_assert_is_setup(ev);
 
        if (ev->ev_flags & EVLIST_INSERTED)
@@ -1869,6 +1870,8 @@ event_pending(const struct event *ev, short event, struct timeval *tv)
 #endif
        }
 
+       EVBASE_RELEASE_LOCK(ev->ev_base, th_base_lock);
+
        return (flags & event);
 }