]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: wdt: do not remap SI_TKILL to SI_LWP, test the values directly
authorWilly Tarreau <w@1wt.eu>
Fri, 8 Oct 2021 13:31:04 +0000 (15:31 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 8 Oct 2021 15:22:26 +0000 (17:22 +0200)
We used to remap SI_TKILL to SI_LWP when SI_TKILL was not available
(e.g. FreeBSD) but that's ugly and since we need this only in a single
switch/case block in wdt.c it's even simpler and cleaner to perform the
two tests there, so let's do this.

include/haproxy/compat.h
src/wdt.c

index edcbcd50e0e1ef34501872efc15c5d9fbcb90766..25b15a1f0f7b0cb1a308d25fdfdc996969e2d00f 100644 (file)
@@ -23,7 +23,6 @@
 #define _HAPROXY_COMPAT_H
 
 #include <limits.h>
-#include <signal.h>
 #include <unistd.h>
 /* This is needed on Linux for Netfilter includes */
 #include <sys/param.h>
@@ -154,11 +153,6 @@ typedef struct { } empty_t;
 #define F_SETPIPE_SZ (1024 + 7)
 #endif
 
-/* On FreeBSD we don't have SI_TKILL but SI_LWP instead */
-#if !defined(SI_TKILL) && defined(SI_LWP)
-#define SI_TKILL SI_LWP
-#endif
-
 #if defined(USE_TPROXY) && defined(USE_NETFILTER)
 #include <linux/types.h>
 #include <linux/netfilter_ipv6.h>
index d1428a55621ed5133c7f356d9b9cc097775cd3b7..96db84bd9b187b02a1719187ab01f2f0bbe45bfd 100644 (file)
--- a/src/wdt.c
+++ b/src/wdt.c
@@ -104,11 +104,21 @@ void wdt_handler(int sig, siginfo_t *si, void *arg)
 
                /* No doubt now, there's no hop to recover, die loudly! */
                break;
-#ifdef USE_THREAD
+
+#if defined(USE_THREAD) && defined(SI_TKILL) /* Linux uses this */
+
        case SI_TKILL:
                /* we got a pthread_kill, stop on it */
                thr = tid;
                break;
+
+#elif defined(USE_THREAD) && defined(SI_LWP) /* FreeBSD uses this */
+
+       case SI_LWP:
+               /* we got a pthread_kill, stop on it */
+               thr = tid;
+               break;
+
 #endif
        default:
                /* unhandled other conditions */