From 12997e9d800734da51b808767e1e2477244c30eb Mon Sep 17 00:00:00 2001 From: bert hubert Date: Thu, 8 Jan 2015 16:59:33 +0100 Subject: [PATCH] improve timeout reporting in rec_control --- pdns/rec_channel.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pdns/rec_channel.cc b/pdns/rec_channel.cc index 1b28b1edc..e08484e8a 100644 --- a/pdns/rec_channel.cc +++ b/pdns/rec_channel.cc @@ -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) -- 2.40.0