X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fntpd.c;h=baa1988b26596665b0a5936042de5ecd9a113f80;hp=39bbeeb5f5413cc7764f7273fc55d809d36e43e7;hb=06a86a60a7dabc685bdbd81ce3d36ea5f7e2c2d4;hpb=8e5e2e927f9cf051ef210473b1b48ff62d81f585 diff --git a/src/ntpd.c b/src/ntpd.c index 39bbeeb5..baa1988b 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -56,17 +56,17 @@ static const char *config_keys[] = {"Host", "Port", "ReverseLookups", "IncludeUnitID"}; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); -static _Bool do_reverse_lookups = 1; +static bool do_reverse_lookups = true; /* This option only exists for backward compatibility. If it is false and two * ntpd peers use the same refclock driver, the plugin will try to write * simultaneous measurements from both to the same type instance. */ -static _Bool include_unit_id = 0; +static bool include_unit_id; #define NTPD_DEFAULT_HOST "localhost" #define NTPD_DEFAULT_PORT "123" static int sock_descr = -1; -static char *ntpd_host = NULL; +static char *ntpd_host; static char ntpd_port[16]; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -272,14 +272,14 @@ static int ntpd_config(const char *key, const char *value) { sstrncpy(ntpd_port, value, sizeof(ntpd_port)); } else if (strcasecmp(key, "ReverseLookups") == 0) { if (IS_TRUE(value)) - do_reverse_lookups = 1; + do_reverse_lookups = true; else - do_reverse_lookups = 0; + do_reverse_lookups = false; } else if (strcasecmp(key, "IncludeUnitID") == 0) { if (IS_TRUE(value)) - include_unit_id = 1; + include_unit_id = true; else - include_unit_id = 0; + include_unit_id = false; } else { return -1; } @@ -584,7 +584,7 @@ static int ntpd_receive_response(int *res_items, int *res_size, char **res_data, * Enough with the checks. Copy the data now. * We start by allocating some more memory. */ - DEBUG("realloc (%p, %zu)", (void *)*res_data, + DEBUG("realloc (%p, %" PRIsz ")", (void *)*res_data, (items_num + pkt_item_num) * res_item_size); items = realloc(*res_data, (items_num + pkt_item_num) * res_item_size); if (items == NULL) { @@ -717,7 +717,7 @@ ntpd_get_refclock_id(struct info_peer_summary const *peer_info) { static int ntpd_get_name_from_address(char *buffer, size_t buffer_size, struct info_peer_summary const *peer_info, - _Bool do_reverse_lookup) { + bool do_reverse_lookup) { struct sockaddr_storage sa = {0}; socklen_t sa_len; int flags = 0; @@ -883,6 +883,12 @@ static int ntpd_read(void) { continue; } + // `0.0.0.0` hosts are caused by POOL servers + // see https://github.com/collectd/collectd/issues/2358 + if (strcmp(peername, "0.0.0.0") == 0) { + continue; + } + refclock_id = ntpd_get_refclock_id(ptr); /* Convert the `long floating point' offset value to double */