[collectd] ntpd plugin complaining [FIXED finally]
Luboš Staněk
lubek at users.sourceforge.net
Fri Nov 3 22:39:55 CET 2006
Hi Florian,
I have got it. :))
Although it took a huge amount of time, it is solved.
It is a simple programming logic mistake. It is not connected to the
IPv6 stack, the DNS functions or ntpd functions at all.
I am glad that it is not due to the errors in my systems. :)
But I found many things concerning IPv6 and setup working IPv6 stack on
my testing machine with the help of the tunneling IPv6 over IPV4 due to
this error. Thanks.
Frankly, I doubt that your current ntpd plugin code can work anywhere
well. And if yes, it must be only a hell luck.
There are only two possibilities. The number of ntpd servers are so
small that their info_peer_summaries fit into one packet or the system
does not overwrite the released memory - collects lower number of servers.
Here is the part of the debug log, I sent you:
Polling for 1000ms
recv'd 440 bytes
pkt_item_num = 6; pkt_item_len = 72;
*res_size = 72
res_item_size = 72; pkt_padding = 0;
realloc ((nil), 432)
Polling for 1000ms
recv'd 152 bytes
pkt_item_num = 2; pkt_item_len = 72;
*res_size = 72
res_item_size = 72; pkt_padding = 0;
Last sequence = 1;
realloc (0x83e75f0, 144)
The error comes up with the second "*res_size = 72" and realloc
(0x83e75f0, 144).
It means that the res_data list was shrinked to 144 from 432 instead of
enlarging it to 576!
This part of the code should run only once in the polling loop.
if (items_num == 0) /* first packet */
{
DBG ("*res_size = %i", pkt_item_len);
*res_size = pkt_item_len;
}
I have repaired it this way (the last line is appended):
items = realloc ((void *) *res_data,
(items_num + pkt_item_num) * res_item_size);
+items_num = items_num + pkt_item_num;
And I would like to mention a part of the getnameinfo() man page.
"In order to assist the programmer in choosing reasonable sizes for the
supplied buffers, <netdb.h> defines the constants"
# define NI_MAXHOST 1025
# define NI_MAXSERV 32
I would recommend enlarging the peername[512] to peername[NI_MAXHOST]
therefore.
Best regars,
Lubos
More information about the collectd
mailing list