From 5648c27c150c66df417269f1daa398e1dc2f6a86 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Fri, 30 Nov 2018 13:55:32 +0200 Subject: [PATCH] pdns_notify: Implement 60 second timeout --- pdns/notify.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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()<