From 7ad6899d3736c52960fbe6a5b0fda5b81759f83c Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 8 Dec 2023 14:31:58 +0100 Subject: [PATCH] write_riemann plugin: Unify reference counting code with other plugins. --- src/write_riemann.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/write_riemann.c b/src/write_riemann.c index 1196e9113..b4ed2c199 100644 --- a/src/write_riemann.c +++ b/src/write_riemann.c @@ -617,15 +617,14 @@ static void wrr_free(void *p) /* {{{ */ pthread_mutex_lock(&host->lock); host->reference_count--; - int reference_count = host->reference_count; - pthread_mutex_unlock(&host->lock); - - if (reference_count > 0) { + if (host->reference_count > 0) { + pthread_mutex_unlock(&host->lock); return; } wrr_disconnect(host); + pthread_mutex_unlock(&host->lock); pthread_mutex_destroy(&host->lock); sfree(host); } /* }}} void wrr_free */ -- 2.47.2