X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdns.c;h=c8e794eb032f83dd786455767819214548c758a3;hb=19a7c076959e16df16be966d4c3aa563431ef038;hp=ae53710b24783dbf5193eacd242833e07e6414af;hpb=51bc7c4a5523f2b03c24e32064b28c7c8426534d;p=collectd.git diff --git a/src/dns.c b/src/dns.c index ae53710b..c8e794eb 100644 --- a/src/dns.c +++ b/src/dns.c @@ -278,30 +278,16 @@ static int dns_run_pcap_loop (void) static int dns_sleep_one_interval (void) /* {{{ */ { - cdtime_t interval; - struct timespec ts = { 0, 0 }; - int status = 0; - - interval = plugin_get_interval (); - CDTIME_T_TO_TIMESPEC (interval, &ts); - - while (42) + struct timespec ts = CDTIME_T_TO_TIMESPEC (plugin_get_interval ()); + while (nanosleep (&ts, &ts) != 0) { - struct timespec rem = { 0, 0 }; - - status = nanosleep (&ts, &rem); - if (status == 0) - break; - else if ((errno == EINTR) || (errno == EAGAIN)) - { - ts = rem; + if ((errno == EINTR) || (errno == EAGAIN)) continue; - } - else - break; + + return (errno); } - return (status); + return (0); } /* }}} int dns_sleep_one_interval */ static void *dns_child_loop (__attribute__((unused)) void *dummy) /* {{{ */ @@ -374,7 +360,6 @@ static void submit_derive (const char *type, const char *type_instance, vl.values = &(value_t) { .derive = value }; vl.values_len = 1; - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "dns", sizeof (vl.plugin)); sstrncpy (vl.type, type, sizeof (vl.type)); sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); @@ -392,7 +377,6 @@ static void submit_octets (derive_t queries, derive_t responses) vl.values = values; vl.values_len = STATIC_ARRAY_SIZE (values); - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "dns", sizeof (vl.plugin)); sstrncpy (vl.type, "dns_octets", sizeof (vl.type));