From c7d1aee76d5713d1f337ab1c831c0ed74e4676e1 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Thu, 27 Dec 2018 18:56:16 +0200 Subject: Multiple files: reduce work while under lock. Mostly, unlock before logging. In some cases, moved different code that was not needed to be under lock (for example, taking time, or malloc'ing) to be executed before taking the lock. Note: logging might be slightly less accurate in order, since it may not be done now under the lock, so order of logs is racy. I think it's a reasonable compromise. Compile-tested only! updates: bz#1193929 Signed-off-by: Yaniv Kaul Change-Id: I2438710016afc9f4f62a176ef1a0d3ed793b4f89 --- libglusterfs/src/rbthash.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libglusterfs/src/rbthash.c') diff --git a/libglusterfs/src/rbthash.c b/libglusterfs/src/rbthash.c index 1bdd45f9fae..ae2e158d61e 100644 --- a/libglusterfs/src/rbthash.c +++ b/libglusterfs/src/rbthash.c @@ -252,10 +252,11 @@ rbthash_insert_entry(rbthash_table_t *tbl, rbthash_entry_t *entry) LOCK(&bucket->bucketlock); { if (!rb_probe(bucket->bucket, (void *)entry)) { + UNLOCK(&bucket->bucketlock); gf_msg(GF_RBTHASH, GF_LOG_ERROR, 0, LG_MSG_RBTHASH_INSERT_FAILED, - "Failed to insert" - " entry"); + "Failed to insert entry"); ret = -1; + goto err; } } UNLOCK(&bucket->bucketlock); -- cgit