From: Luke Heberling Date: Thu, 20 Aug 2009 12:08:53 +0000 (+0200) Subject: powerdns plugin: Set a timeout for the datagram socket. X-Git-Tag: collectd-4.6.5~20 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7595db879edf643aff84a77791bf50d757554125;p=collectd.git powerdns plugin: Set a timeout for the datagram socket. → See also: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=535787 --- diff --git a/src/powerdns.c b/src/powerdns.c index 164137ba..09ad8353 100644 --- a/src/powerdns.c +++ b/src/powerdns.c @@ -380,6 +380,18 @@ static int powerdns_get_data_dgram (list_item_t *item, /* {{{ */ break; } + struct timeval timeout; + timeout.tv_sec=2; + if (timeout.tv_sec < interval_g * 3 / 4) + timeout.tv_sec = interval_g * 3 / 4; + timeout.tv_usec=0; + status = setsockopt (sd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof (timeout)); + if (status != 0) + { + FUNC_ERROR ("setsockopt"); + break; + } + status = connect (sd, (struct sockaddr *) &item->sockaddr, sizeof (item->sockaddr)); if (status != 0)