// ------------------------------------------------------------------------
// free it
- if(host->rrdpush_spawn) {
- pthread_cancel(host->rrdpush_thread);
- rrdpush_sender_thread_cleanup(host);
- }
+ rrdpush_sender_thread_stop(host);
freez(host->os);
freez(host->cache_dir);
rrdpush_unlock(host);
}
-void rrdpush_sender_thread_cleanup(RRDHOST *host) {
+static void rrdpush_sender_thread_cleanup(RRDHOST *host) {
rrdpush_lock(host);
host->rrdpush_connected = 0;
rrdpush_unlock(host);
}
+void rrdpush_sender_thread_stop(RRDHOST *host) {
+ rrdhost_check_wrlock(host);
+
+ if(host->rrdpush_spawn) {
+ info("STREAM %s [send]: stopping sending thread...", host->hostname);
+ pthread_cancel(host->rrdpush_thread);
+ rrdpush_sender_thread_cleanup(host);
+ }
+}
+
void *rrdpush_sender_thread(void *ptr) {
RRDHOST *host = (RRDHOST *)ptr;
if(health_enabled == CONFIG_BOOLEAN_AUTO)
host->health_enabled = 0;
- if(host->rrdpush_spawn) {
- pthread_cancel(host->rrdpush_thread);
- rrdpush_sender_thread_cleanup(host);
- }
+ rrdpush_sender_thread_stop(host);
}
rrdhost_unlock(host);
extern void *rrdpush_sender_thread(void *ptr);
extern int rrdpush_receiver_thread_spawn(RRDHOST *host, struct web_client *w, char *url);
-extern void rrdpush_sender_thread_cleanup(RRDHOST *host);
+extern void rrdpush_sender_thread_stop(RRDHOST *host);
#endif //NETDATA_RRDPUSH_H