]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
write_prometheus plugin: Fix a deadlock due to a leaked mutex. 4285/head
authorFlorian Forster <octo@collectd.org>
Mon, 19 Feb 2024 22:30:49 +0000 (23:30 +0100)
committerFlorian Forster <octo@collectd.org>
Mon, 19 Feb 2024 22:30:49 +0000 (23:30 +0100)
src/write_prometheus.c

index 893d680a7020435e96b4396fd3f47882dc660bf3..edeef4d46dae58ea6cb0751ecf8cb679b948a48f 100644 (file)
@@ -824,8 +824,10 @@ static int prom_missing(metric_family_t const *fam,
   pthread_mutex_lock(&prom_metrics_lock);
 
   metric_family_t *prom_fam = NULL;
-  if (c_avl_get(prom_metrics, fam->name, (void *)&prom_fam) != 0)
+  if (c_avl_get(prom_metrics, fam->name, (void *)&prom_fam) != 0) {
+    pthread_mutex_unlock(&prom_metrics_lock);
     return 0;
+  }
 
   for (size_t i = 0; i < fam->metric.num; i++) {
     metric_t const *m = &fam->metric.ptr[i];