83 lines
2.1 KiB
Diff
83 lines
2.1 KiB
Diff
|
From 633817ad53adbdeb4054b750e1f0bd4ce58f341b Mon Sep 17 00:00:00 2001
|
||
|
From: Marius Tomaschewski <mt@suse.de>
|
||
|
Date: Thu, 20 Dec 2012 10:25:53 +0100
|
||
|
Subject: [PATCH] Ignore SIGPIPE to not die in socket code
|
||
|
References: bnc#794578
|
||
|
Upstream: sent [ISC-Bugs #32222]
|
||
|
|
||
|
Installed SIG_IGN handler for SIGPIPE to not die before
|
||
|
the errno==EPIPE checks in the socket code are reached.
|
||
|
Unlike isc_app_start(), the isc_app_ctxstart() used by
|
||
|
dhcp, does not set any signal handlers.
|
||
|
|
||
|
Reported upstream as [ISC-Bugs #32222], IMO regression
|
||
|
to [ISC-Bugs #22269] as the SO_NOSIGPIPE socket option
|
||
|
isn't available e.g. on Linux.
|
||
|
|
||
|
Signed-off-by: Marius Tomaschewski <mt@suse.de>
|
||
|
---
|
||
|
omapip/isclib.c | 33 ++++++++++++++++++++++++++++++++-
|
||
|
1 Datei geändert, 32 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
|
||
|
|
||
|
diff --git a/omapip/isclib.c b/omapip/isclib.c
|
||
|
index 1534dde..27bb887 100644
|
||
|
--- a/omapip/isclib.c
|
||
|
+++ b/omapip/isclib.c
|
||
|
@@ -28,6 +28,7 @@
|
||
|
#include "dhcpd.h"
|
||
|
|
||
|
#include <sys/time.h>
|
||
|
+#include <signal.h>
|
||
|
|
||
|
dhcp_context_t dhcp_gbl_ctx;
|
||
|
|
||
|
@@ -67,6 +68,23 @@ isclib_cleanup(void)
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
+static isc_result_t
|
||
|
+handle_signal(int sig, void (*handler)(int)) {
|
||
|
+ struct sigaction sa;
|
||
|
+
|
||
|
+ memset(&sa, 0, sizeof(sa));
|
||
|
+ sa.sa_handler = handler;
|
||
|
+
|
||
|
+ if (sigfillset(&sa.sa_mask) != 0 ||
|
||
|
+ sigaction(sig, &sa, NULL) < 0) {
|
||
|
+ log_error("handle_signal() %d setup: %s",
|
||
|
+ sig, strerror(errno));
|
||
|
+ return (ISC_R_UNEXPECTED);
|
||
|
+ }
|
||
|
+
|
||
|
+ return (ISC_R_SUCCESS);
|
||
|
+}
|
||
|
+
|
||
|
isc_result_t
|
||
|
dhcp_context_create(void) {
|
||
|
isc_result_t result;
|
||
|
@@ -104,7 +122,20 @@ dhcp_context_create(void) {
|
||
|
|
||
|
result = isc_app_ctxstart(dhcp_gbl_ctx.actx);
|
||
|
if (result != ISC_R_SUCCESS)
|
||
|
- return (result);
|
||
|
+ goto cleanup;
|
||
|
+
|
||
|
+ /*
|
||
|
+ * Always ignore SIGPIPE.
|
||
|
+ * Otherwise we will die before the errno == EPIPE
|
||
|
+ * checks in the socket code are reached.
|
||
|
+ *
|
||
|
+ * Note: unlike isc_app_start(), isc_app_ctxstart()
|
||
|
+ * does not set any signal handlers.
|
||
|
+ */
|
||
|
+ result = handle_signal(SIGPIPE, SIG_IGN);
|
||
|
+ if (result != ISC_R_SUCCESS)
|
||
|
+ goto cleanup;
|
||
|
+
|
||
|
dhcp_gbl_ctx.actx_started = ISC_TRUE;
|
||
|
|
||
|
result = isc_taskmgr_createinctx(dhcp_gbl_ctx.mctx,
|
||
|
--
|
||
|
1.7.10.4
|
||
|
|