summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e09db53)
raw | patch | inline | side by side (parent: e09db53)
author | Florian Forster <octo@collectd.org> | |
Sun, 11 Nov 2012 09:57:55 +0000 (10:57 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Sun, 11 Nov 2012 09:58:06 +0000 (10:58 +0100) |
This may happen when the network is down. If the thread fails, the read
callback will indicate an error and the exponential back-off will start.
This is not optimal for this scenario, since you usually want to have
ping stats from right when the network is back up.
Fixes Github issue #171.
callback will indicate an error and the exponential back-off will start.
This is not optimal for this scenario, since you usually want to have
ping stats from right when the network is back up.
Fixes Github issue #171.
src/ping.c | patch | blob | history |
diff --git a/src/ping.c b/src/ping.c
index 51a7e777abca2a21d75daa3a37b81e162d741e1e..ab1459e3a938544d29fab7b2c7777205b3b48f1f 100644 (file)
--- a/src/ping.c
+++ b/src/ping.c
#include "common.h"
#include "plugin.h"
#include "configfile.h"
+#include "utils_complain.h"
#include <pthread.h>
#include <netinet/in.h>
hostlist_t *hl;
int count;
+ c_complain_t complaint = C_COMPLAIN_INIT_STATIC;
+
pthread_mutex_lock (&ping_lock);
pingobj = ping_construct ();
while (ping_thread_loop > 0)
{
int status;
+ _Bool send_successful = 0;
if (gettimeofday (&tv_begin, NULL) < 0)
{
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);
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)
{