From 7595db879edf643aff84a77791bf50d757554125 Mon Sep 17 00:00:00 2001 From: Luke Heberling Date: Thu, 20 Aug 2009 14:08:53 +0200 Subject: [PATCH] powerdns plugin: Set a timeout for the datagram socket. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit → See also: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=535787 --- src/powerdns.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) -- 2.30.2