From f5d29e6317583bb19d8a47063c435634333912ea Mon Sep 17 00:00:00 2001 From: Roman Khapov Date: Mon, 28 Oct 2024 20:19:09 +0500 Subject: [PATCH] sources/hashmap.c: fix lock (#706) pthread_mutex_trylock returns non-zero, when mutex is not locked, so current usage will sleep when mutex is locked succesfully Signed-off-by: rkhapov Co-authored-by: rkhapov --- sources/hashmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/hashmap.c b/sources/hashmap.c index 0096e50f0..83d0c9b71 100644 --- a/sources/hashmap.c +++ b/sources/hashmap.c @@ -224,7 +224,7 @@ od_hashmap_elt_t *od_hashmap_lock_key(od_hashmap_t *hm, od_hash_t keyhash, * To avoid intra-machine locks we must yield cpu slice from time to time * even if waiting for other lock. */ - while (!pthread_mutex_trylock(&hm->buckets[bucket_index]->mu)) + while (pthread_mutex_trylock(&hm->buckets[bucket_index]->mu)) machine_sleep(1); od_hashmap_elt_t *ptr = od_bucket_search(hm->buckets[bucket_index],