diff options
author | Andrew Moss <1043609+amoss@users.noreply.github.com> | 2020-06-08 23:43:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-08 23:43:56 +0200 |
commit | 3e1d5eb977be0f56dfe32f5d746ded1ad6213346 (patch) | |
tree | 0e0e4b581e09e5691c1ef49ad8908527260514b7 | |
parent | ecd9c48238a4db2ab6ef2bb4e98d75093773df69 (diff) |
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.
-rw-r--r-- | streaming/receiver.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/streaming/receiver.c b/streaming/receiver.c index 39a606e291..380d49137c 100644 --- a/streaming/receiver.c +++ b/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()); |