Module: check_mk
Branch: master
Commit: 68ee4716145e871785e5aba177ce25fa49e8e30c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=68ee4716145e87…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Jun 23 13:42:57 2017 +0200
4695 FIX Make communication with event console more robust
When the monitoring core connects to the event console very rapidly, a "No
buffer space available" error could happen intermittently. This can be seen
in the log, and the corresponding command fails, too, e.g. archiving an
event. This has been fixed, the connection is simply retried when this
rare but harmless error happens.
Change-Id: Id382dfe9f4267bb7d660ac306a963a3e622a8041
---
.werks/4695 | 14 ++++++++++++++
livestatus/src/EventConsoleConnection.cc | 23 ++++++++++++++++++++++-
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/.werks/4695 b/.werks/4695
new file mode 100644
index 0000000..793fecd
--- /dev/null
+++ b/.werks/4695
@@ -0,0 +1,14 @@
+Title: Make communication with event console more robust
+Level: 1
+Component: livestatus
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1498217686
+Class: fix
+
+When the monitoring core connects to the event console very rapidly, a "No
+buffer space available" error could happen intermittently. This can be seen
+in the log, and the corresponding command fails, too, e.g. archiving an
+event. This has been fixed, the connection is simply retried when this
+rare but harmless error happens.
diff --git a/livestatus/src/EventConsoleConnection.cc
b/livestatus/src/EventConsoleConnection.cc
index 61fbb61..474d31f 100644
--- a/livestatus/src/EventConsoleConnection.cc
+++ b/livestatus/src/EventConsoleConnection.cc
@@ -26,8 +26,12 @@
// IWYU pragma: no_include <boost/asio/basic_socket_streambuf.hpp>
#include "EventConsoleConnection.h"
#include <boost/asio/socket_base.hpp>
+#include <boost/system/error_code.hpp>
#include <boost/system/system_error.hpp>
+#include <chrono>
#include <ostream>
+#include <ratio>
+#include <thread>
#include <utility>
#include "Logger.h"
@@ -43,7 +47,24 @@ EventConsoleConnection::~EventConsoleConnection() {
void EventConsoleConnection::run() {
boost::asio::local::stream_protocol::endpoint ep(_path);
- boost::asio::local::stream_protocol::iostream stream(ep);
+ // Attention, tricky timing-dependent stuff ahead: When we connect very
+ // rapidly, a no_buffer_space (= ENOBUFS) error can happen. This is probably
+ // caused by some internal Boost Kung Fu, remapping EGAIN to ENOBUFS, and
+ // looks like a bug in Boost, but that's a bit unclear. So instead of
+ // relying on Boost to retry under these circumstances, we do it ourselves.
+ boost::asio::local::stream_protocol::iostream stream;
+ while (true) {
+ stream.connect(ep);
+ if (stream.error() !=
+ boost::system::error_code(boost::system::errc::no_buffer_space,
+ boost::system::system_category())) {
+ break;
+ }
+ Debug(_logger) << "retrying to connect";
+ stream.clear();
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
+ }
+
check(stream, "connect");
Debug(_logger) << prefix("successfully connected");