mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 14:44:32 +02:00
Revert "ExternalCommandListener: Use threads per client connection"
This reverts commit accd83693ce699be5538a60facf1d11b5ec3ac57
This commit is contained in:
parent
f6a7f84ed5
commit
dae120beb6
@ -99,7 +99,6 @@ void ExternalCommandListener::CommandPipeThread(const String& commandPath)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
try {
|
|
||||||
do {
|
do {
|
||||||
fd = open(commandPath.CStr(), O_RDONLY);
|
fd = open(commandPath.CStr(), O_RDONLY);
|
||||||
} while (fd < 0 && errno == EINTR);
|
} while (fd < 0 && errno == EINTR);
|
||||||
@ -111,18 +110,6 @@ void ExternalCommandListener::CommandPipeThread(const String& commandPath)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Log(LogNotice, "ExternalCommandListener", "Client connected");
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(&ExternalCommandListener::ClientHandler, this, commandPath, fd));
|
|
||||||
} catch (std::exception&) {
|
|
||||||
Log(LogCritical, "ExternalCommandListener", "Cannot accept new connection.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExternalCommandListener::ClientHandler(const String& commandPath, int fd)
|
|
||||||
{
|
|
||||||
FILE *fp = fdopen(fd, "r");
|
FILE *fp = fdopen(fd, "r");
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
@ -140,7 +127,6 @@ void ExternalCommandListener::ClientHandler(const String& commandPath, int fd)
|
|||||||
while (strlen(line) > 0 &&
|
while (strlen(line) > 0 &&
|
||||||
(line[strlen(line) - 1] == '\r' || line[strlen(line) - 1] == '\n'))
|
(line[strlen(line) - 1] == '\r' || line[strlen(line) - 1] == '\n'))
|
||||||
line[strlen(line) - 1] = '\0';
|
line[strlen(line) - 1] = '\0';
|
||||||
}
|
|
||||||
|
|
||||||
String command = line;
|
String command = line;
|
||||||
|
|
||||||
@ -152,10 +138,11 @@ void ExternalCommandListener::ClientHandler(const String& commandPath, int fd)
|
|||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "External command failed.";
|
msgbuf << "External command failed.";
|
||||||
Log(LogWarning, "ExternalCommandListener", msgbuf.str());
|
Log(LogWarning, "ExternalCommandListener", msgbuf.str());
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete line;
|
delete line;
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
@ -49,7 +49,6 @@ private:
|
|||||||
boost::thread m_CommandThread;
|
boost::thread m_CommandThread;
|
||||||
|
|
||||||
void CommandPipeThread(const String& commandPath);
|
void CommandPipeThread(const String& commandPath);
|
||||||
void ClientHandler(const String& commandPath, int fd);
|
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user