]> granicus.if.org Git - pdns/commitdiff
auth: Handle `read()` returning 0 in RemoteBackend's unix connector
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 10 Jun 2016 12:29:31 +0000 (14:29 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 10 Jun 2016 12:29:31 +0000 (14:29 +0200)
Otherwise it looks like we may loop in `recv_message()` until the
timeout is reached if the other end closes the connection:
* `waitForData()` will return immediately
* `read()` will keep returning 0

modules/remotebackend/unixconnector.cc

index 5c5a7216fcfd7b05d3557c11bba293e9a7e33bb8..f997183e21352754e8666805e72f721aa19714ba 100644 (file)
@@ -89,7 +89,7 @@ ssize_t UnixsocketConnector::read(std::string &data) {
   // just try again later...
   if (nread==-1 && errno == EAGAIN) return 0;
 
-  if (nread==-1) {
+  if (nread==-1 || nread==0) {
     connected = false;
     close(fd);
     return -1;