]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Use the timeout passed to rec_control for sending too 7242/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 29 Nov 2018 10:28:37 +0000 (11:28 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 29 Nov 2018 10:28:37 +0000 (11:28 +0100)
pdns/rec_channel.cc
pdns/rec_channel.hh
pdns/rec_control.cc

index 2bbb54c1a3d50fbbe2b7bb1ea9d65c9f548bbf29..cec4dff6a75eccce80eb9df256ab54cd32022526 100644 (file)
@@ -108,8 +108,16 @@ void RecursorControlChannel::connect(const string& path, const string& fname)
   }
 }
 
-void RecursorControlChannel::send(const std::string& msg, const std::string* remote)
+void RecursorControlChannel::send(const std::string& msg, const std::string* remote, unsigned int timeout)
 {
+  int ret = waitForRWData(d_fd, false, timeout, 0);
+  if(ret == 0) {
+    throw PDNSException("Timeout sending message over control channel");
+  }
+  else if(ret < 0) {
+    throw PDNSException("Error sending message over control channel:" + string(strerror(errno)));
+  }
+
   if(remote) {
     struct sockaddr_un remoteaddr;
     memset(&remoteaddr, 0, sizeof(remoteaddr));
index 1b8e4d8f308a0a57411887bb4bbd96a6076a0dac..0fadd4125986dd89cd8cd1be0a5aff6ec9ce508e 100644 (file)
@@ -44,7 +44,7 @@ public:
 
   uint64_t getStat(const std::string& name);
 
-  void send(const std::string& msg, const std::string* remote=0);
+  void send(const std::string& msg, const std::string* remote=nullptr, unsigned int timeout=5);
   std::string recv(std::string* remote=0, unsigned int timeout=5);
 
   int d_fd;
index 90f6fd1c218d6071c54d9feec207a50c12e86ba4..56f6776c36140649bfb886358b7eaa34b5019ed1 100644 (file)
@@ -104,7 +104,7 @@ try
       command+=" ";
     command+=commands[i];
   }
-  rccS.send(command);
+  rccS.send(command, nullptr, arg().asNum("timeout"));
   string receive=rccS.recv(0, arg().asNum("timeout"));
   if(receive.compare(0, 7, "Unknown") == 0) {
     cerr<<receive<<endl;