diff options
author | Azat Khuzhin <azat@libevent.org> | 2023-02-12 08:34:52 +0100 |
---|---|---|
committer | Azat Khuzhin <azat@libevent.org> | 2023-02-12 08:49:47 +0100 |
commit | c257e16f5bf48ad947b00f4eb59ace34f9b136d1 (patch) | |
tree | dff62fef7cea28765b8d3f3cafe0e1347a6d0cd8 | |
parent | fb900a284f23fe6317b7ad6f8992f4f584364be5 (diff) | |
download | libevent-c257e16f5bf48ad947b00f4eb59ace34f9b136d1.tar.gz |
test: fix debug locks in case new lock gots old address
Refs: #1407
-rw-r--r-- | test/regress_bufferevent.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/regress_bufferevent.c b/test/regress_bufferevent.c index 83cb804b..0775a523 100644 --- a/test/regress_bufferevent.c +++ b/test/regress_bufferevent.c @@ -254,10 +254,18 @@ static lock_wrapper *lu_find(void *lock_) static void *trace_lock_alloc(unsigned locktype) { void *lock; + lock_wrapper *existing_lock; + + lock = lu_base.cbs.alloc(locktype); + existing_lock = lu_find(lock); + if (existing_lock) { + existing_lock->status = ALLOC; + return lock; + } + ++lu_base.nr_locks; lu_base.locks = realloc(lu_base.locks, sizeof(lock_wrapper) * lu_base.nr_locks); - lock = lu_base.cbs.alloc(locktype); lu_base.locks[lu_base.nr_locks - 1] = (lock_wrapper){ lock, ALLOC, 0 }; return lock; } |