From: Remi Gacogne Date: Fri, 5 Jul 2019 08:19:04 +0000 (+0200) Subject: dnsdist: Handle ENOTCONN on read() over TCP X-Git-Tag: dnsdist-1.4.0-rc1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8030%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Handle ENOTCONN on read() over TCP When a non-blocking connect() has returned `EINPROGRESS`, it looks like BSD can return `ENOTCONN` on `read()` even after a `write()` succeeded. --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index 994ba9a1bb..9ce3b74f4d 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -361,7 +361,7 @@ IOState tryRead(int fd, std::vector& 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 { diff --git a/pdns/tcpiohandler.hh b/pdns/tcpiohandler.hh index 3e7f52b081..ac6525888a 100644 --- a/pdns/tcpiohandler.hh +++ b/pdns/tcpiohandler.hh @@ -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 {