From: Florian Forster Date: Fri, 8 Dec 2023 13:31:58 +0000 (+0100) Subject: write_riemann plugin: Unify reference counting code with other plugins. X-Git-Tag: 6.0.0-rc0~38^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4176%2Fhead;p=thirdparty%2Fcollectd.git write_riemann plugin: Unify reference counting code with other plugins. --- 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 */