diff --git a/src/ntpd.c b/src/ntpd.c
index 40c2aa47053ad5629392fd5e48be2b368d5ba8a4..e37b3a1cefad037e286dd4bde0cd640940740898 100644 (file)
--- a/src/ntpd.c
+++ b/src/ntpd.c
#if HAVE_NETINET_TCP_H
# include <netinet/tcp.h>
#endif
#if HAVE_NETINET_TCP_H
# include <netinet/tcp.h>
#endif
-#if HAVE_SYS_POLL_H
-# include <sys/poll.h>
+#if HAVE_POLL_H
+# include <poll.h>
#endif
static char *config_keys[] =
#endif
static char *config_keys[] =
static char *time_delay_file = "ntpd/delay-%s.rrd";
/* used for `time_offset', `time_dispersion', and `delay' */
static char *time_delay_file = "ntpd/delay-%s.rrd";
/* used for `time_offset', `time_dispersion', and `delay' */
-static char *ms_ds_def[] =
+static char *sec_ds_def[] =
{
{
- "DS:ms:GAUGE:"COLLECTD_HEARTBEAT":-1000000:1000000",
+ "DS:seconds:GAUGE:"COLLECTD_HEARTBEAT":-1000000:1000000",
NULL
};
NULL
};
-static int ms_ds_num = 1;
+static int sec_ds_num = 1;
static char *frequency_offset_file = "ntpd/frequency_offset-%s.rrd";
static char *frequency_offset_ds_def[] =
static char *frequency_offset_file = "ntpd/frequency_offset-%s.rrd";
static char *frequency_offset_ds_def[] =
return;
}
return;
}
-static void ntpd_write_ms (char *host, char *inst, char *val, char *file)
+static void ntpd_write_sec (char *host, char *inst, char *val, char *file)
{
char buf[256];
int status;
{
char buf[256];
int status;
return;
rrd_update_file (host, buf, val,
return;
rrd_update_file (host, buf, val,
- ms_ds_def, ms_ds_num);
+ sec_ds_def, sec_ds_num);
}
static void ntpd_write_time_offset (char *host, char *inst, char *val)
{
}
static void ntpd_write_time_offset (char *host, char *inst, char *val)
{
- ntpd_write_ms (host, inst, val, time_offset_file);
+ ntpd_write_sec (host, inst, val, time_offset_file);
}
static void ntpd_write_time_dispersion (char *host, char *inst, char *val)
{
}
static void ntpd_write_time_dispersion (char *host, char *inst, char *val)
{
- ntpd_write_ms (host, inst, val, time_dispersion_file);
+ ntpd_write_sec (host, inst, val, time_dispersion_file);
}
static void ntpd_write_delay (char *host, char *inst, char *val)
{
}
static void ntpd_write_delay (char *host, char *inst, char *val)
{
- ntpd_write_ms (host, inst, val, time_delay_file);
+ ntpd_write_sec (host, inst, val, time_delay_file);
}
static void ntpd_write_frequency_offset (char *host, char *inst, char *val)
}
static void ntpd_write_frequency_offset (char *host, char *inst, char *val)
if (status < 0)
{
DBG ("recv(2) failed: %s", strerror (errno));
if (status < 0)
{
DBG ("recv(2) failed: %s", strerror (errno));
+ DBG ("Closing socket #%i", sd);
+ close (sd);
+ sock_descr = sd = -1;
return (-1);
}
return (-1);
}
(items_num + pkt_item_num) * res_item_size);
items = realloc ((void *) *res_data,
(items_num + pkt_item_num) * res_item_size);
(items_num + pkt_item_num) * res_item_size);
items = realloc ((void *) *res_data,
(items_num + pkt_item_num) * res_item_size);
+ items_num += pkt_item_num;
if (items == NULL)
{
items = *res_data;
if (items == NULL)
{
items = *res_data;
@@ -758,7 +762,12 @@ static int ntpd_send_request (int req_code, int req_items, int req_size, char *r
status = swrite (sd, (const char *) &req, REQ_LEN_NOMAC);
if (status < 0)
status = swrite (sd, (const char *) &req, REQ_LEN_NOMAC);
if (status < 0)
+ {
+ DBG ("`swrite' failed. Closing socket #%i", sd);
+ close (sd);
+ sock_descr = sd = -1;
return (status);
return (status);
+ }
return (0);
}
return (0);
}
struct info_peer_summary *ptr;
double offset;
struct info_peer_summary *ptr;
double offset;
- char peername[512];
+ char peername[NI_MAXHOST];
int refclock_id;
ptr = ps + i;
int refclock_id;
ptr = ps + i;
if (ptr->v6_flag)
{
if (ptr->v6_flag)
{
- status = getnameinfo ((const struct sockaddr *) &ptr->srcadr6,
- sizeof (ptr->srcadr6),
+ struct sockaddr_in6 sa;
+
+ memset (&sa, 0, sizeof (sa));
+ sa.sin6_family = AF_INET6;
+ sa.sin6_port = htons (123);
+ memcpy (&sa.sin6_addr, &ptr->srcadr6, sizeof (struct in6_addr));
+
+ status = getnameinfo ((const struct sockaddr *) &sa,
+ sizeof (sa),
peername, sizeof (peername),
NULL, 0, 0 /* no flags */);
if (status != 0)
peername, sizeof (peername),
NULL, 0, 0 /* no flags */);
if (status != 0)