From: Remi Gacogne Date: Fri, 16 Dec 2022 14:46:34 +0000 (+0100) Subject: channel: Cleaner handling of EOF when writing on the pipe X-Git-Tag: rec-5.0.0-alpha1~161^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43ec3a214ff399857971bff1d074356a01bc8e26;p=thirdparty%2Fpdns.git channel: Cleaner handling of EOF when writing on the pipe --- diff --git a/pdns/channel.cc b/pdns/channel.cc index bebbdf4380..ce2f0ef60c 100644 --- a/pdns/channel.cc +++ b/pdns/channel.cc @@ -37,6 +37,9 @@ namespace channel char data = 'a'; while (true) { auto sent = write(d_fd.getHandle(), &data, sizeof(data)); + if (sent == 0) { + throw std::runtime_error("Unable to write to channel notifier pipe: remote end has been closed"); + } if (sent != sizeof(data)) { if (errno == EINTR) { continue; diff --git a/pdns/channel.hh b/pdns/channel.hh index 9835ab68a2..ff34e9f990 100644 --- a/pdns/channel.hh +++ b/pdns/channel.hh @@ -234,6 +234,9 @@ namespace channel object.release(); return true; } + else if (sent == 0) { + throw std::runtime_error("Unable to write to channel: remote end has been closed"); + } else { #if __SANITIZE_THREAD__ __tsan_acquire(ptr);