From: Azat Khuzhin Date: Sun, 12 Feb 2023 07:34:52 +0000 (+0100) Subject: test: fix debug locks in case new lock gots old address X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c257e16f5bf48ad947b00f4eb59ace34f9b136d1;p=libevent test: fix debug locks in case new lock gots old address Refs: #1407 --- 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; }