#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 */
/* we have 4 buffer-wait queues, in highest to lowest emergency order */
#define DYNBUF_NBQ 4
if (!buf || (ulong)buf & 0x1UL)
return;
+ /* inform callees to be careful, we're in a signal handler! */
+ _HA_ATOMIC_OR(&th_ctx->flags, TH_FL_IN_SIG_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
* is that all threads keep a copy of their own dump.
*/
while (no_return)
wait(NULL);
+
+ _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_SIG_HANDLER);
}
static int init_debug_per_thread()
*/
void signal_handler(int sig)
{
+ /* inform callees to be careful, we're in a signal handler! */
+ _HA_ATOMIC_OR(&th_ctx->flags, TH_FL_IN_SIG_HANDLER);
+
if (sig < 0 || sig >= MAX_SIGNAL) {
/* unhandled signal */
signal(sig, SIG_IGN);
qfprintf(stderr, "Received unhandled signal %d. Signal has been disabled.\n", sig);
+ _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_SIG_HANDLER);
return;
}
/* If the thread is TH_FL_SLEEPING we need to wake it */
wake_thread(tid);
+ _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_SIG_HANDLER);
}
/* Call handlers of all pending signals and clear counts and queue length. The
ulong thr_bit;
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);
+
switch (si->si_code) {
case SI_TIMER:
/* A thread's timer fired, the thread ID is in si_int. We have
#endif
default:
/* unhandled other conditions */
+ _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_SIG_HANDLER);
return;
}
else
#endif
ha_panic();
+
+ _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_SIG_HANDLER);
return;
update_and_leave:
wdt_ping(thr);
+
+ _HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_IN_SIG_HANDLER);
}
/* parse the "warn-blocked-traffic-after" parameter */