X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fping.c;h=5df82f475cb935383d629a23186bee2754382979;hb=3d7453f6c3a13dc49e9ed6dd6d7a19202a3b087e;hp=d669aa937d4b15f187e7d3c69edd4f2d341b25f9;hpb=649eff4e6f96ba72d693c1442acaa62abdf965e0;p=collectd.git diff --git a/src/ping.c b/src/ping.c index d669aa93..5df82f47 100644 --- a/src/ping.c +++ b/src/ping.c @@ -241,7 +241,7 @@ static int ping_dispatch_all (pingobj_t *pingobj) /* {{{ */ static void *ping_thread (void *arg) /* {{{ */ { - static pingobj_t *pingobj = NULL; + pingobj_t *pingobj = NULL; struct timeval tv_begin; struct timeval tv_end; @@ -379,7 +379,7 @@ static int start_thread (void) /* {{{ */ if (ping_thread_loop != 0) { pthread_mutex_unlock (&ping_lock); - return (-1); + return (0); } ping_thread_loop = 1; @@ -393,7 +393,7 @@ static int start_thread (void) /* {{{ */ pthread_mutex_unlock (&ping_lock); return (-1); } - + pthread_mutex_unlock (&ping_lock); return (0); } /* }}} int start_thread */ @@ -421,8 +421,10 @@ static int stop_thread (void) /* {{{ */ status = -1; } + pthread_mutex_lock (&ping_lock); memset (&ping_thread_id, 0, sizeof (ping_thread_id)); ping_thread_error = 0; + pthread_mutex_unlock (&ping_lock); return (status); } /* }}} int stop_thread */ @@ -442,10 +444,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, /* {{{ */