]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
write_riemann plugin: Unify reference counting code with other plugins. 4176/head
authorFlorian Forster <octo@collectd.org>
Fri, 8 Dec 2023 13:31:58 +0000 (14:31 +0100)
committerFlorian Forster <octo@collectd.org>
Tue, 12 Dec 2023 09:51:32 +0000 (10:51 +0100)
src/write_riemann.c

index 1196e911324936a2ce220d3c53d15d9fac7a1900..b4ed2c19949345471d706d418a5da245a3ac22fe 100644 (file)
@@ -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 */