Permalink
Browse files

improve timeout reporting in rec_control

  • Loading branch information...
1 parent b71b60e commit 12997e9d800734da51b808767e1e2477244c30eb @ahupowerdns ahupowerdns committed Jan 8, 2015
Showing with 6 additions and 2 deletions.
  1. +6 −2 pdns/rec_channel.cc
View
@@ -121,8 +121,12 @@ string RecursorControlChannel::recv(std::string* remote, unsigned int timeout)
ssize_t len;
struct sockaddr_un remoteaddr;
socklen_t addrlen=sizeof(remoteaddr);
-
- if((waitForData(d_fd, timeout, 0 ) != 1) || (len=::recvfrom(d_fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&remoteaddr, &addrlen)) < 0)
+
+ int ret=waitForData(d_fd, timeout, 0);
+ if(ret==0)
+ throw PDNSException("Timeout waiting for answer from control channel");
+
+ if( ret < 0 || (len=::recvfrom(d_fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&remoteaddr, &addrlen)) < 0)
throw PDNSException("Unable to receive message over control channel: "+string(strerror(errno)));
if(remote)

0 comments on commit 12997e9

Please sign in to comment.