From 67a330cb7ba890a03142a089ed1aebea8842072f Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sat, 6 Aug 2016 18:22:56 +0200 Subject: [PATCH] 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 --- src/ping.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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, /* {{{ */ -- 2.30.2