Merge branch 'collectd-5.4' into collectd-5.5
[collectd.git] / src / statsd.c
index d12cb0d..54b6e94 100644 (file)
@@ -941,8 +941,6 @@ static int statsd_shutdown (void) /* {{{ */
   void *key;
   void *value;
 
-  pthread_mutex_lock (&metrics_lock);
-
   if (network_thread_running)
   {
     network_thread_shutdown = 1;
@@ -951,6 +949,8 @@ static int statsd_shutdown (void) /* {{{ */
   }
   network_thread_running = 0;
 
+  pthread_mutex_lock (&metrics_lock);
+
   while (c_avl_pick (metrics_tree, &key, &value) == 0)
   {
     sfree (key);