Add upstream patches for Icinga2 so that opening a fifo doesn't block

open()s in other threads, fixing an issue where the daemon doesn't start
correctly when the command listener is enabled.

Many thanks to dnsmichi and gunnarbeutner from Icinga for tracking this
down and fixing it.
This commit is contained in:
sthen 2015-11-09 22:36:38 +00:00
parent 316c58dcf0
commit bc79fa9427
5 changed files with 137 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.38 2015/10/21 19:10:34 sthen Exp $
# $OpenBSD: Makefile,v 1.39 2015/11/09 22:36:38 sthen Exp $
BROKEN-hppa = needs 64-bit atomic ops; __sync_add_and_fetch_4
SHARED_ONLY = Yes
@ -9,7 +9,7 @@ COMMENT-pgsql = PostgreSQL support for icinga2
V = 2.3.11
REVISION = 1
REVISION-main = 3
REVISION-main = 4
EPOCH = 0
GH_ACCOUNT = Icinga
GH_PROJECT = icinga2

View File

@ -0,0 +1,75 @@
$OpenBSD: patch-lib_base_utility_cpp,v 1.1 2015/11/09 22:36:38 sthen Exp $
commit 9ea51aa86edac407411376d2ed18a494368b9e31
Author: Gunnar Beutner <gunnar@beutner.name>
Date: Mon Nov 9 20:39:26 2015 +0100
Use non-blocking open() for the command pipe
fixes #10410
--- lib/base/utility.cpp.orig Mon Oct 19 10:14:40 2015
+++ lib/base/utility.cpp Mon Nov 9 21:42:01 2015
@@ -844,7 +844,7 @@ bool Utility::SetFileOwnership(const String& file, con
}
#ifndef _WIN32
-void Utility::SetNonBlocking(int fd)
+void Utility::SetNonBlocking(int fd, bool nb)
{
int flags = fcntl(fd, F_GETFL, 0);
@@ -854,14 +854,19 @@ void Utility::SetNonBlocking(int fd)
<< boost::errinfo_errno(errno));
}
- if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
+ if (nb)
+ flags |= O_NONBLOCK;
+ else
+ flags &= ~O_NONBLOCK;
+
+ if (fcntl(fd, F_SETFL, flags) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< boost::errinfo_api_function("fcntl")
<< boost::errinfo_errno(errno));
}
}
-void Utility::SetCloExec(int fd)
+void Utility::SetCloExec(int fd, bool cloexec)
{
int flags = fcntl(fd, F_GETFD, 0);
@@ -871,7 +876,12 @@ void Utility::SetCloExec(int fd)
<< boost::errinfo_errno(errno));
}
- if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
+ if (cloexec)
+ flags |= FD_CLOEXEC;
+ else
+ flags &= ~FD_CLOEXEC;
+
+ if (fcntl(fd, F_SETFD, flags) < 0) {
BOOST_THROW_EXCEPTION(posix_error()
<< boost::errinfo_api_function("fcntl")
<< boost::errinfo_errno(errno));
@@ -879,13 +889,13 @@ void Utility::SetCloExec(int fd)
}
#endif /* _WIN32 */
-void Utility::SetNonBlockingSocket(SOCKET s)
+void Utility::SetNonBlockingSocket(SOCKET s, bool nb)
{
#ifndef _WIN32
- SetNonBlocking(s);
+ SetNonBlocking(s, nb);
#else /* _WIN32 */
- unsigned long lTrue = 1;
- ioctlsocket(s, FIONBIO, &lTrue);
+ unsigned long lflag = nb;
+ ioctlsocket(s, FIONBIO, &lflag);
#endif /* _WIN32 */
}

View File

@ -0,0 +1,27 @@
$OpenBSD: patch-lib_base_utility_hpp,v 1.1 2015/11/09 22:36:38 sthen Exp $
commit 9ea51aa86edac407411376d2ed18a494368b9e31
Author: Gunnar Beutner <gunnar@beutner.name>
Date: Mon Nov 9 20:39:26 2015 +0100
Use non-blocking open() for the command pipe
fixes #10410
--- lib/base/utility.hpp.orig Mon Oct 19 10:14:40 2015
+++ lib/base/utility.hpp Mon Nov 9 21:42:01 2015
@@ -101,11 +101,11 @@ class I2_BASE_API Utility (public)
static void ExecuteDeferredInitializers(void);
#ifndef _WIN32
- static void SetNonBlocking(int fd);
- static void SetCloExec(int fd);
+ static void SetNonBlocking(int fd, bool nb = true);
+ static void SetCloExec(int fd, bool cloexec = true);
#endif /* _WIN32 */
- static void SetNonBlockingSocket(SOCKET s);
+ static void SetNonBlockingSocket(SOCKET s, bool nb = true);
static String EscapeShellCmd(const String& s);
static String EscapeShellArg(const String& s);

View File

@ -0,0 +1,33 @@
$OpenBSD: patch-lib_compat_externalcommandlistener_cpp,v 1.1 2015/11/09 22:36:38 sthen Exp $
commit 9ea51aa86edac407411376d2ed18a494368b9e31
Author: Gunnar Beutner <gunnar@beutner.name>
Date: Mon Nov 9 20:39:26 2015 +0100
Use non-blocking open() for the command pipe
fixes #10410
--- lib/compat/externalcommandlistener.cpp.orig Mon Oct 19 10:14:40 2015
+++ lib/compat/externalcommandlistener.cpp Mon Nov 9 21:42:01 2015
@@ -93,17 +93,15 @@ void ExternalCommandListener::CommandPipeThread(const
}
for (;;) {
- int fd;
+ int fd = open(commandPath.CStr(), O_RDONLY | O_NONBLOCK);
- do {
- fd = open(commandPath.CStr(), O_RDONLY);
- } while (fd < 0 && errno == EINTR);
-
if (fd < 0) {
Log(LogCritical, "ExternalCommandListener")
<< "open() for fifo path '" << commandPath << "' failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
return;
}
+
+ Utility::SetNonBlocking(fd, false);
FILE *fp = fdopen(fd, "r");

View File

@ -11,7 +11,3 @@ inherited from Nagios as a fork.
* Intuitive to configure, using new object-based, template-driven format
* Easy to extend with native support for Livestatus and Graphite
* Cluster-enabled for distributed monitoring out of the box
+----------------------------------------------------------------+
| WARNING: This package is not considered stable on OpenBSD yet. |
+----------------------------------------------------------------+