X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fping.c;h=8bbb80765f54a1b76021b3be4dea1ad5d49a832d;hb=9f6f901889d4c9f594b5ae1fd0f449fcdd2d8fe3;hp=51a7e777abca2a21d75daa3a37b81e162d741e1e;hpb=e09db531fa5ec2ce997154e4ad5d4fdee298f94a;p=collectd.git diff --git a/src/ping.c b/src/ping.c index 51a7e777..8bbb8076 100644 --- a/src/ping.c +++ b/src/ping.c @@ -23,6 +23,7 @@ #include "common.h" #include "plugin.h" #include "configfile.h" +#include "utils_complain.h" #include #include @@ -245,6 +246,8 @@ static void *ping_thread (void *arg) /* {{{ */ hostlist_t *hl; int count; + c_complain_t complaint = C_COMPLAIN_INIT_STATIC; + pthread_mutex_lock (&ping_lock); pingobj = ping_construct (); @@ -305,6 +308,7 @@ static void *ping_thread (void *arg) /* {{{ */ while (ping_thread_loop > 0) { int status; + _Bool send_successful = 0; if (gettimeofday (&tv_begin, NULL) < 0) { @@ -320,10 +324,13 @@ static void *ping_thread (void *arg) /* {{{ */ status = ping_send (pingobj); if (status < 0) { - ERROR ("ping plugin: ping_send failed: %s", ping_get_error (pingobj)); - pthread_mutex_lock (&ping_lock); - ping_thread_error = 1; - break; + c_complain (LOG_ERR, &complaint, "ping plugin: ping_send failed: %s", + ping_get_error (pingobj)); + } + else + { + c_release (LOG_NOTICE, &complaint, "ping plugin: ping_send succeeded."); + send_successful = 1; } pthread_mutex_lock (&ping_lock); @@ -331,7 +338,8 @@ static void *ping_thread (void *arg) /* {{{ */ if (ping_thread_loop <= 0) break; - (void) ping_dispatch_all (pingobj); + if (send_successful) + (void) ping_dispatch_all (pingobj); if (gettimeofday (&tv_end, NULL) < 0) { @@ -371,7 +379,7 @@ static int start_thread (void) /* {{{ */ ping_thread_loop = 1; ping_thread_error = 0; - status = pthread_create (&ping_thread_id, /* attr = */ NULL, + status = plugin_thread_create (&ping_thread_id, /* attr = */ NULL, ping_thread, /* arg = */ (void *) 0); if (status != 0) {