diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-02-25 13:49:33 +0200 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-02-25 13:49:33 +0200 |
commit | 69520035d8893339bffc354febf5da5c4f7dabbe (patch) | |
tree | 52575de3ed015f5ad09430b57f18d77df42bc4f4 /src/rrdpush.c | |
parent | 38ebad296fa94b9e1e481b4f2a542034dbeebb96 (diff) |
avoid code duplication
Diffstat (limited to 'src/rrdpush.c')
-rw-r--r-- | src/rrdpush.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/rrdpush.c b/src/rrdpush.c index 729544b5a3..a283495555 100644 --- a/src/rrdpush.c +++ b/src/rrdpush.c @@ -206,7 +206,7 @@ static inline void rrdpush_sender_thread_unlock(RRDHOST *host) { 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; @@ -235,6 +235,16 @@ void rrdpush_sender_thread_cleanup(RRDHOST *host) { 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; @@ -554,10 +564,7 @@ int rrdpush_receive(int fd, const char *key, const char *hostname, const char *m 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); |