]> granicus.if.org Git - icinga2/commitdiff
Revert "Use threads for external commands"
authorGunnar Beutner <gunnar.beutner@netways.de>
Thu, 21 Aug 2014 07:36:05 +0000 (09:36 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 21 Aug 2014 07:36:05 +0000 (09:36 +0200)
This reverts commit e1b8b05ef3034ede65fb84141a5a3a908304ddd5.

components/compat/externalcommandlistener.cpp
components/compat/externalcommandlistener.hpp

index f9361095518a2d79ad9773c82e02378625bc227f..a4f76a4d9ae1c929529f8dba5b4a73dffc437f73 100644 (file)
@@ -113,8 +113,6 @@ void ExternalCommandListener::CommandPipeThread(const String& commandPath)
                FILE *fp = fdopen(fd, "r");
 
                if (fp == NULL) {
-                       (void) close(fd);
-
                        std::ostringstream msgbuf;
                        msgbuf << "fdopen() for fifo path '" << commandPath << "' failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
                        Log(LogCritical, "ExternalCommandListener",  msgbuf.str());
@@ -130,24 +128,21 @@ void ExternalCommandListener::CommandPipeThread(const String& commandPath)
                            (line[strlen(line) - 1] == '\r' || line[strlen(line) - 1] == '\n'))
                                line[strlen(line) - 1] = '\0';
 
-                       Utility::QueueAsyncCallback(boost::bind(&ExternalCommandListener::ExecuteCommand, line));
+                       String command = line;
+
+                       try {
+                               Log(LogInformation, "ExternalCommandListener", "Executing external command: " + command);
+
+                               ExternalCommandProcessor::Execute(command);
+                       } catch (const std::exception&) {
+                               std::ostringstream msgbuf;
+                               msgbuf << "External command failed.";
+                               Log(LogWarning, "ExternalCommandListener", msgbuf.str());
+                       }
                }
 
                delete line;
                fclose(fp);
        }
 }
-
-void ExternalCommandListener::ExecuteCommand(const String& command)
-{
-       try {
-               Log(LogInformation, "ExternalCommandListener", "Executing external command: " + command);
-
-               ExternalCommandProcessor::Execute(command);
-       } catch (const std::exception&) {
-               std::ostringstream msgbuf;
-               msgbuf << "External command failed: " << command;
-               Log(LogWarning, "ExternalCommandListener", msgbuf.str());
-       }
-}
 #endif /* _WIN32 */
index 342a3d2b7ea64160b21c42f415292b9a10bb5df5..0006aec33567ee64e5f79fb6314b8565cfd50f6c 100644 (file)
@@ -49,7 +49,6 @@ private:
        boost::thread m_CommandThread;
 
        void CommandPipeThread(const String& commandPath);
-       static void ExecuteCommand(const String& command);
 #endif /* _WIN32 */
 };