From: Aki Tuomi Date: Fri, 30 Nov 2018 11:55:32 +0000 (+0200) Subject: pdns_notify: Implement 60 second timeout X-Git-Tag: rec-4.2.0-alpha1~53^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5648c27c150c66df417269f1daa398e1dc2f6a86;p=pdns pdns_notify: Implement 60 second timeout --- diff --git a/pdns/notify.cc b/pdns/notify.cc index 270aaad36..d44577145 100644 --- a/pdns/notify.cc +++ b/pdns/notify.cc @@ -121,11 +121,32 @@ try } char buffer[1500]; + fd_set rfds; + FD_ZERO(&rfds); + FD_SET(sock, &rfds); + int len; + struct timeval tv; + bool timeout = true; + + for(int tries=0; tries<60; tries++) { + tv.tv_sec = 1; + tv.tv_usec = 0; + if ((len = select(sock+1, &rfds, NULL, &rfds, &tv)) > 0) { + len = recv(sock, buffer, sizeof(buffer), 0); + timeout = false; + break; + } + } - int len=recv(sock, buffer, sizeof(buffer),0); if(len < 0) { cerr<<"Unable to receive notification response from PowerDNS: "+stringerror()<