Browse Source

Fix crash in #9291 (#9297)

Did not account for the path where rrdhost_find_or_create fails and terminates the thread before setting rpt->host to a valid pointer.
Andrew Moss 4 years ago
parent
commit
3e1d5eb977
1 changed files with 6 additions and 4 deletions
  1. 6 4
      streaming/receiver.c

+ 6 - 4
streaming/receiver.c

@@ -11,10 +11,12 @@ static void rrdpush_receiver_thread_cleanup(void *ptr) {
         struct receiver_state *rpt = (struct receiver_state *) ptr;
 
         // Make sure that we detach this thread and don't kill a freshly arriving receiver
-        netdata_mutex_lock(&rpt->host->receiver_lock);
-        if (rpt->host->receiver == rpt)
-            rpt->host->receiver = NULL;
-        netdata_mutex_unlock(&rpt->host->receiver_lock);
+        if (rpt->host) {
+            netdata_mutex_lock(&rpt->host->receiver_lock);
+            if (rpt->host->receiver == rpt)
+                rpt->host->receiver = NULL;
+            netdata_mutex_unlock(&rpt->host->receiver_lock);
+        }
 
         info("STREAM %s [receive from [%s]:%s]: receive thread ended (task id %d)", rpt->hostname, rpt->client_ip, rpt->client_port, gettid());