Remove PID file later in the cleanup process --kevin
[rrdtool.git] / src / rrd_daemon.c
index 2a35ec2..f0ad729 100644 (file)
@@ -924,9 +924,6 @@ static void *queue_thread_main (void *args __attribute__((unused))) /* {{{ */
       pthread_cond_broadcast(&ci->flushed);
     pthread_mutex_unlock(&cache_lock);
 
-    rrd_free_ptrs((void ***) &values, &values_num);
-    free(file);
-
     if (status == 0)
     {
       pthread_mutex_lock (&stats_lock);
@@ -935,6 +932,9 @@ static void *queue_thread_main (void *args __attribute__((unused))) /* {{{ */
       pthread_mutex_unlock (&stats_lock);
     }
 
+    rrd_free_ptrs((void ***) &values, &values_num);
+    free(file);
+
     pthread_mutex_lock (&cache_lock);
   }
   pthread_mutex_unlock (&cache_lock);
@@ -2528,7 +2528,6 @@ static int cleanup (void) /* {{{ */
   }
 
   journal_done();
-  remove_pidfile ();
 
   free(queue_threads);
   free(config_base_dir);
@@ -2542,6 +2541,8 @@ static int cleanup (void) /* {{{ */
   RRDD_LOG(LOG_INFO, "goodbye");
   closelog ();
 
+  remove_pidfile ();
+
   return (0);
 } /* }}} int cleanup */