summaryrefslogtreecommitdiff
path: root/evthread.c
diff options
context:
space:
mode:
authorAzat Khuzhin <a3at.mail@gmail.com>2015-10-04 03:49:38 +0300
committerAzat Khuzhin <a3at.mail@gmail.com>2015-10-04 03:50:40 +0300
commite4556fcda78dda92bfcaf0926a5c0264fc008d23 (patch)
tree99a8a1a64d75b73f8be1ffce22a71a84884ff4f6 /evthread.c
parentf337296a5cf259903c4f37e67c1a7f903af39fa0 (diff)
downloadlibevent-e4556fcda78dda92bfcaf0926a5c0264fc008d23.tar.gz
evthread: fix evthread_setup_global_lock_() for debug-lock with a real-lock case
Sample bt: (gdb) bt #0 0x00000000004a95d2 in evthread_setup_global_lock_ (lock_=0x0, locktype=0, enable_locks=1) #1 0x00000000004afbc7 in evsig_global_setup_locks_ (enable_locks=1) at signal.c:475 #2 0x00000000004a5da8 in event_global_setup_locks_ (enable_locks=1) at event.c:3838 #3 0x00000000004a8983 in evthread_set_lock_callbacks (cbs=0x7fffffffdde0) at evthread.c:129 #4 0x0000000000445a8f in use_lock_unlock_profiler () at regress_bufferevent.c:306 #5 0x0000000000445af2 in test_bufferevent_pair_release_lock (arg=0x70e710) at regress_bufferevent.c:327 #6 0x000000000048c9a8 in testcase_run_bare_ (testcase=0x6fdc10 <bufferevent_testcases+80>) at tinytest.c:105 #7 0x000000000048cc8a in testcase_run_one (group=0x6ff270 <testgroups+112>, testcase=0x6fdc10 <bufferevent_testcases+80>) at tinytest.c:252 #8 0x000000000048d5c9 in tinytest_main (c=3, v=0x7fffffffe008, groups=0x6ff200 <testgroups>) at tinytest.c:434 #9 0x000000000047a08f in main (argc=3, argv=0x7fffffffe008) at regress_main.c:459 Found-with: regress bufferevent/bufferevent_pair_release_lock (-DEVENT__DISABLE_DEBUG_MODE=ON)
Diffstat (limited to 'evthread.c')
-rw-r--r--evthread.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/evthread.c b/evthread.c
index b8c5fb63..f3f1eddc 100644
--- a/evthread.c
+++ b/evthread.c
@@ -401,17 +401,18 @@ evthread_setup_global_lock_(void *lock_, unsigned locktype, int enable_locks)
return evthread_lock_fns_.alloc(locktype);
} else {
/* Case 4: Fill in a debug lock with a real lock */
- struct debug_lock *lock = lock_;
+ struct debug_lock *lock = lock_ ? lock_ : debug_lock_alloc(locktype);
EVUTIL_ASSERT(enable_locks &&
evthread_lock_debugging_enabled_);
EVUTIL_ASSERT(lock->locktype == locktype);
- EVUTIL_ASSERT(lock->lock == NULL);
- lock->lock = original_lock_fns_.alloc(
- locktype|EVTHREAD_LOCKTYPE_RECURSIVE);
if (!lock->lock) {
- lock->count = -200;
- mm_free(lock);
- return NULL;
+ lock->lock = original_lock_fns_.alloc(
+ locktype|EVTHREAD_LOCKTYPE_RECURSIVE);
+ if (!lock->lock) {
+ lock->count = -200;
+ mm_free(lock);
+ return NULL;
+ }
}
return lock;
}