Module: check_mk
Branch: master
Commit: 95704aa49d708924d9fd123cb72172eda0a38ad3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=95704aa49d7089…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue May 8 11:21:40 2018 +0200
Check for failed accept().
Change-Id: Ic1d74843d8ab48d030e7d22f8b42181dff89e242
---
livestatus/src/module.cc | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/livestatus/src/module.cc b/livestatus/src/module.cc
index bf50124..7f43f90 100644
--- a/livestatus/src/module.cc
+++ b/livestatus/src/module.cc
@@ -194,8 +194,10 @@ void *main_thread(void *data) {
if (retval > 0 &&
poller.isFileDescriptorSet(g_unix_socket, PollEvents::in)) {
int cc = accept(g_unix_socket, nullptr, nullptr);
- if (cc > g_max_fd_ever) {
- g_max_fd_ever = cc;
+ if (cc == -1) {
+ generic_error ge("cannot accept client connection");
+ Warning(fl_logger_livestatus) << ge;
+ continue;
}
if (fcntl(cc, F_SETFD, FD_CLOEXEC) == -1) {
generic_error ge(
@@ -203,6 +205,9 @@ void *main_thread(void *data) {
Alert(fl_logger_livestatus) << ge;
break;
}
+ if (cc > g_max_fd_ever) {
+ g_max_fd_ever = cc;
+ }
fl_client_queue->addConnection(cc); // closes fd
g_num_queued_connections++;
counterIncrement(Counter::connections);