]> granicus.if.org Git - libevent/commitdiff
test: fix bufferevent/bufferevent_pair_release_lock in debug mode
authorAzat Khuzhin <a3at.mail@gmail.com>
Thu, 10 Sep 2015 10:38:58 +0000 (13:38 +0300)
committerAzat Khuzhin <a3at.mail@gmail.com>
Thu, 10 Sep 2015 10:44:07 +0000 (13:44 +0300)
After this test had been fixed for freebsd the debug build was broken because
we can't call evthread_set_lock_callbacks() when something already initialized,
and we can't call event_base_free() (in kqueue case) when it is initialized,
because of "held_by", but this only playing role during freeing lock profiler
so reset lock callbacks there before and this will fix both.

Fixes: 79f9ace4ae8a259a5cf1b4ff3869078b60ff16a1 ("test: fix
bufferevent/bufferevent_pair_release_lock for freebsd")

P.S. after this patch 'make verify' finishes without errors on freebsd.

test/regress_bufferevent.c

index 989778d983bfee1d059d5fabffd46ee9f9465a58..2599cdd91c413f0808d01fd04eb642db8ff8da47 100644 (file)
@@ -276,14 +276,13 @@ static int trace_lock_unlock(unsigned mode, void *lock_)
 }
 static void lock_unlock_free_thread_cbs(void)
 {
-       /** drop immutable flag */
-       evthread_set_lock_callbacks(NULL);
-
        event_base_free(NULL);
 
        if (libevent_tests_running_in_debug_mode)
                libevent_global_shutdown();
 
+       /** drop immutable flag */
+       evthread_set_lock_callbacks(NULL);
        /** avoid calling of event_global_setup_locks_() for new cbs */
        libevent_global_shutdown();
        /** drop immutable flag for non-debug ops (since called after shutdown) */
@@ -315,6 +314,9 @@ static int use_lock_unlock_profiler(void)
 }
 static void free_lock_unlock_profiler(struct basic_test_data *data)
 {
+       /** fix "held_by" for kqueue */
+       evthread_set_lock_callbacks(NULL);
+
        lock_unlock_free_thread_cbs();
        free(lu_base.locks);
        data->base = NULL;