]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Handle ENOTCONN on read() over TCP 8030/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 5 Jul 2019 08:19:04 +0000 (10:19 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 5 Jul 2019 08:19:04 +0000 (10:19 +0200)
When a non-blocking connect() has returned `EINPROGRESS`, it looks
like BSD can return `ENOTCONN` on `read()` even after a `write()`
succeeded.

pdns/dnsdist-tcp.cc
pdns/tcpiohandler.hh

index 994ba9a1bb8a78b6e91b3bd206120a0ed3b623dc..9ce3b74f4dd4044114b840e4bd42108e2e0d4c07 100644 (file)
@@ -361,7 +361,7 @@ IOState tryRead(int fd, std::vector<uint8_t>& buffer, size_t& pos, size_t toRead
       throw runtime_error("EOF while reading message");
     }
     if (res < 0) {
-      if (errno == EAGAIN || errno == EWOULDBLOCK) {
+      if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOTCONN) {
         return IOState::NeedRead;
       }
       else {
index 3e7f52b081553bc239ff9628f4e608e6692d7b68..ac6525888ab922ce2b7efab6b6bb715c01cd4a8d 100644 (file)
@@ -214,7 +214,7 @@ public:
         throw runtime_error("EOF while reading message");
       }
       if (res < 0) {
-        if (errno == EAGAIN || errno == EWOULDBLOCK) {
+        if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOTCONN) {
           return IOState::NeedRead;
         }
         else {
@@ -250,7 +250,7 @@ public:
         throw runtime_error("EOF while sending message");
       }
       if (res < 0) {
-        if (errno == EAGAIN || errno == EWOULDBLOCK) {
+        if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOTCONN) {
           return IOState::NeedWrite;
         }
         else {