summaryrefslogtreecommitdiffstats
path: root/streaming/rrdpush.h
diff options
context:
space:
mode:
authorAndrew Moss <1043609+amoss@users.noreply.github.com>2020-06-19 19:37:47 +0200
committerGitHub <noreply@github.com>2020-06-19 19:37:47 +0200
commit85752833adac111cf01ae558ee0c46b3a76aed69 (patch)
tree1594cb6ddbe49ad98b43b4ffb25c25fc760d60d9 /streaming/rrdpush.h
parent51cff0660b0eb671dbec42e54d7567db8b6ba712 (diff)
Fixes the race-hazard in streaming during the shutdown sequence (#9370)
The streaming component detects when a receiver stream has closed, and stops an attached sender on the same host. This is to support proxy configurations where the stream is passed through. During the shutdown sequence, once netdata_exit has been set no thread should touch any RRDHOST structure as the non-static threads are not joined before the database shuts down. The destruction of the thread state has been separated from the cleanup and can be called from two points. If the thread can detach itself from the host (i.e. it is not during the shutdown sequence) then it does so and destroys the state. During shutdown the thread leaves the state intact so that it can be destroyed during the host destruction, and the host destruction now cancels the thread to ensure a consistent sequence of events.
Diffstat (limited to 'streaming/rrdpush.h')
-rw-r--r--streaming/rrdpush.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/streaming/rrdpush.h b/streaming/rrdpush.h
index efbf2f1e6f..f747b69b2d 100644
--- a/streaming/rrdpush.h
+++ b/streaming/rrdpush.h
@@ -64,6 +64,7 @@ struct sender_state {
struct receiver_state {
RRDHOST *host;
+ netdata_thread_t thread;
int fd;
char *key;
char *hostname;
@@ -85,7 +86,8 @@ struct receiver_state {
#ifdef ENABLE_HTTPS
struct netdata_ssl ssl;
#endif
- unsigned int shutdown:1;
+ unsigned int shutdown:1; // Tell the thread to exit
+ unsigned int exited; // Indicates that the thread has exited (NOT A BITFIELD!)
};