From: Florian Forster Date: Sat, 6 Aug 2016 16:22:56 +0000 (+0200) Subject: ping plugin: Let start_thread() return gracefully when thread is already running. X-Git-Tag: collectd-5.6.0~3^2~7^2~2 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=67a330cb7ba890a03142a089ed1aebea8842072f;p=collectd.git ping plugin: Let start_thread() return gracefully when thread is already running. Signaling an error caused the init function to signal an error, causing the read callback to be unregistered on systems where init is called more than once. Fixes: #869 --- diff --git a/src/ping.c b/src/ping.c index ecbbd9d0..fca730f5 100644 --- a/src/ping.c +++ b/src/ping.c @@ -374,7 +374,7 @@ static int start_thread (void) /* {{{ */ if (ping_thread_loop != 0) { pthread_mutex_unlock (&ping_lock); - return (-1); + return (0); } ping_thread_loop = 1; @@ -388,7 +388,7 @@ static int start_thread (void) /* {{{ */ pthread_mutex_unlock (&ping_lock); return (-1); } - + pthread_mutex_unlock (&ping_lock); return (0); } /* }}} int start_thread */ @@ -439,10 +439,7 @@ static int ping_init (void) /* {{{ */ "Will use a timeout of %gs.", ping_timeout); } - if (start_thread () != 0) - return (-1); - - return (0); + return (start_thread ()); } /* }}} int ping_init */ static int config_set_string (const char *name, /* {{{ */