]> granicus.if.org Git - icinga2/commitdiff
Fix Process timeouts.
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 14 Mar 2014 11:16:49 +0000 (12:16 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 14 Mar 2014 11:16:49 +0000 (12:16 +0100)
Fixes #5759

lib/base/process-unix.cpp

index cd62913b86dab97600301b0891aa67192d6ae806..479ff69b2a6bfeda1b6a60b1bcba0004f741e9a0 100644 (file)
@@ -87,7 +87,9 @@ void Process::IOThreadProc(void)
        int count = 0;
 
        for (;;) {
-               double timeout = 1;
+               double now, timeout = -1;
+
+               now = Utility::GetTime();
 
                {
                        boost::mutex::scoped_lock lock(l_ProcessMutex);
@@ -106,8 +108,12 @@ void Process::IOThreadProc(void)
                                pfds[i].events = POLLIN;
                                pfds[i].revents = 0;
 
-                               if (kv.second->GetTimeout() != 0 && kv.second->GetTimeout() < timeout)
-                                   timeout = kv.second->GetTimeout();
+                               if (kv.second->m_Timeout != 0) {
+                                       double delta = kv.second->m_Timeout - (now - kv.second->m_Result.ExecutionStart);
+
+                                       if (timeout == -1 || delta < timeout)
+                                               timeout = delta;
+                               }
 
                                i++;
                        }
@@ -295,7 +301,7 @@ bool Process::DoEvents(void)
 
                if (rc > 0) {
                        m_OutputStream.write(buffer, rc);
-                       return true;
+                       continue;
                }
 
                break;