]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
channel: Cleaner handling of EOF when writing on the pipe
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 16 Dec 2022 14:46:34 +0000 (15:46 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 13 Jun 2023 07:59:41 +0000 (09:59 +0200)
pdns/channel.cc
pdns/channel.hh

index bebbdf4380b4aff48e041b05a75eed7eafa4ad2e..ce2f0ef60cca53e54b69e0096efa89533e3265f2 100644 (file)
@@ -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;
index 9835ab68a2c84a06699b2b749758bf574e90f84b..ff34e9f990ea8edde5b5705b1099e089fb09ed2b 100644 (file)
@@ -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);