]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Align with pipebackend as per #1137 and #661
authorAki Tuomi <cmouse@desteem.org>
Mon, 9 Dec 2013 11:37:16 +0000 (13:37 +0200)
committerAki Tuomi <cmouse@desteem.org>
Mon, 9 Dec 2013 11:37:42 +0000 (13:37 +0200)
modules/remotebackend/pipeconnector.cc

index 36cf3110ce499c52a795ebdb8795901f7b20a5af..0f8b1b91a40752d20885cfe6311080b417eeccff 100644 (file)
@@ -64,7 +64,8 @@ void PipeConnector::launch() {
     Utility::setCloseOnExec(d_fd2[0]);
     if(!(d_fp=fdopen(d_fd2[0],"r")))
       throw PDNSException("Unable to associate a file pointer with pipe: "+stringerror());
-    setbuf(d_fp,0); // no buffering please, confuses select
+    if (d_timeout) 
+      setbuf(d_fp,0); // no buffering please, confuses select
   }
   else if(!d_pid) { // child
     signal(SIGCHLD, SIG_DFL); // silence a warning from perl
@@ -144,8 +145,12 @@ int PipeConnector::recv_message(rapidjson::Document &output)
      receive.clear();
      if(d_timeout) {
        struct timeval tv;
-       tv.tv_sec = d_timeout/1000;
-       tv.tv_usec = (d_timeout % 1000) * 1000;
+       if (d_timeout) {
+         tv.tv_sec = d_timeout/1000;
+         tv.tv_usec = (d_timeout % 1000) * 1000;
+       } else {
+         memset(&tv,0,sizeof tv); // ensure
+       }
        fd_set rds;
        FD_ZERO(&rds);
        FD_SET(fileno(d_fp),&rds);