diff --git a/include/haproxy/tinfo-t.h b/include/haproxy/tinfo-t.h index a8a3e0d8b..95604b0f5 100644 --- a/include/haproxy/tinfo-t.h +++ b/include/haproxy/tinfo-t.h @@ -65,7 +65,10 @@ enum { #define TH_FL_STARTED 0x00000010 /* set once the thread starts */ #define TH_FL_IN_LOOP 0x00000020 /* set only inside the polling loop */ #define TH_FL_DUMPING_OTHERS 0x00000040 /* thread currently dumping other threads */ -#define TH_FL_IN_SIG_HANDLER 0x00000080 /* thread currently in signal handler */ +#define TH_FL_IN_SIG_HANDLER 0x00000080 /* thread currently in the generic signal handler */ +#define TH_FL_IN_DBG_HANDLER 0x00000100 /* thread currently in the debug signal handler */ +#define TH_FL_IN_WDT_HANDLER 0x00000200 /* thread currently in the wdt signal handler */ +#define TH_FL_IN_ANY_HANDLER 0x00000380 /* mask to test if the thread is in any signal handler */ /* we have 4 buffer-wait queues, in highest to lowest emergency order */ #define DYNBUF_NBQ 4 diff --git a/src/debug.c b/src/debug.c index 2e5c06a9e..147e73ea1 100644 --- a/src/debug.c +++ b/src/debug.c @@ -2379,7 +2379,7 @@ void debug_handler(int sig, siginfo_t *si, void *arg) return; /* inform callees to be careful, we're in a signal handler! */ - _HA_ATOMIC_OR(&th_ctx->flags, TH_FL_IN_SIG_HANDLER); + _HA_ATOMIC_OR(&th_ctx->flags, TH_FL_IN_DBG_HANDLER); /* Special value 0x2 is used during panics and requires that the thread * allocates its own dump buffer among its own trash buffers. The goal @@ -2402,7 +2402,7 @@ void debug_handler(int sig, siginfo_t *si, void *arg) while (no_return) wait(NULL); - _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_SIG_HANDLER); + _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_DBG_HANDLER); } static int init_debug_per_thread() diff --git a/src/stream.c b/src/stream.c index 43e9e7d43..5acb01ed9 100644 --- a/src/stream.c +++ b/src/stream.c @@ -3284,7 +3284,7 @@ static void __strm_dump_to_buffer(struct buffer *buf, const struct show_sess_ctx conn = objt_conn(strm_orig(strm)); /* be careful not to allocate RAM from a signal handler! */ - if (conn && !conn->src && !(th_ctx->flags & TH_FL_IN_SIG_HANDLER)) + if (conn && !conn->src && !(th_ctx->flags & TH_FL_IN_ANY_HANDLER)) conn_get_src(conn); switch (conn && conn->src ? addr_to_str(conn->src, pn, sizeof(pn)) : AF_UNSPEC) { @@ -3324,7 +3324,7 @@ static void __strm_dump_to_buffer(struct buffer *buf, const struct show_sess_ctx strm_li(strm) ? strm_li(strm)->luid : 0); /* be careful not to allocate RAM from a signal handler! */ - if (conn && !conn->dst && !(th_ctx->flags & TH_FL_IN_SIG_HANDLER)) + if (conn && !conn->dst && !(th_ctx->flags & TH_FL_IN_ANY_HANDLER)) conn_get_dst(conn); switch (conn && conn->dst ? addr_to_str(conn->dst, pn, sizeof(pn)) : AF_UNSPEC) { @@ -3355,7 +3355,7 @@ static void __strm_dump_to_buffer(struct buffer *buf, const struct show_sess_ctx conn = sc_conn(strm->scb); /* be careful not to allocate RAM from a signal handler! */ - if (conn && !conn->src && !(th_ctx->flags & TH_FL_IN_SIG_HANDLER)) + if (conn && !conn->src && !(th_ctx->flags & TH_FL_IN_ANY_HANDLER)) conn_get_src(conn); switch (conn && conn->src ? addr_to_str(conn->src, pn, sizeof(pn)) : AF_UNSPEC) { @@ -3384,7 +3384,7 @@ static void __strm_dump_to_buffer(struct buffer *buf, const struct show_sess_ctx chunk_appendf(buf, "%s server= (id=-1)", pfx); /* be careful not to allocate RAM from a signal handler! */ - if (conn && !conn->dst && !(th_ctx->flags & TH_FL_IN_SIG_HANDLER)) + if (conn && !conn->dst && !(th_ctx->flags & TH_FL_IN_ANY_HANDLER)) conn_get_dst(conn); switch (conn && conn->dst ? addr_to_str(conn->dst, pn, sizeof(pn)) : AF_UNSPEC) { diff --git a/src/wdt.c b/src/wdt.c index b5edece44..be1b65c31 100644 --- a/src/wdt.c +++ b/src/wdt.c @@ -69,7 +69,7 @@ void wdt_handler(int sig, siginfo_t *si, void *arg) int thr, tgrp; /* inform callees to be careful, we're in a signal handler! */ - _HA_ATOMIC_OR(&th_ctx->flags, TH_FL_IN_SIG_HANDLER); + _HA_ATOMIC_OR(&th_ctx->flags, TH_FL_IN_WDT_HANDLER); switch (si->si_code) { case SI_TIMER: @@ -166,7 +166,7 @@ void wdt_handler(int sig, siginfo_t *si, void *arg) #endif default: /* unhandled other conditions */ - _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_SIG_HANDLER); + _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_WDT_HANDLER); return; } @@ -182,13 +182,13 @@ void wdt_handler(int sig, siginfo_t *si, void *arg) #endif ha_panic(); - _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_SIG_HANDLER); + _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_WDT_HANDLER); return; update_and_leave: wdt_ping(thr); - _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_SIG_HANDLER); + _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_WDT_HANDLER); } /* parse the "warn-blocked-traffic-after" parameter */