3333#define TIMER_INVALID ((timer_t)(unsigned long)(0xfffffffful))
3434#endif
3535
36- static timer_t per_thread_wd_timer [MAX_THREADS ];
36+ /* per-thread context for the watchdog, permits to store timers, counters,
37+ * task pointers, etc (anything that helps providing accurate reports).
38+ */
39+ static struct {
40+ timer_t timer ;
41+ } per_thread_wd_ctx [MAX_THREADS ];
3742
3843/* Setup (or ping) the watchdog timer for thread <thr>. Returns non-zero on
3944 * success, zero on failure. It interrupts once per second of CPU time. It
@@ -46,7 +51,7 @@ int wdt_ping(int thr)
4651
4752 its .it_value .tv_sec = 1 ; its .it_value .tv_nsec = 0 ;
4853 its .it_interval .tv_sec = 0 ; its .it_interval .tv_nsec = 0 ;
49- return timer_settime (per_thread_wd_timer [thr ], 0 , & its , NULL ) == 0 ;
54+ return timer_settime (per_thread_wd_ctx [thr ]. timer , 0 , & its , NULL ) == 0 ;
5055}
5156
5257/* This is the WDTSIG signal handler */
@@ -150,7 +155,7 @@ void wdt_handler(int sig, siginfo_t *si, void *arg)
150155
151156int init_wdt_per_thread ()
152157{
153- if (!clock_setup_signal_timer (& per_thread_wd_timer [tid ], WDTSIG , tid ))
158+ if (!clock_setup_signal_timer (& per_thread_wd_ctx [tid ]. timer , WDTSIG , tid ))
154159 goto fail1 ;
155160
156161 if (!wdt_ping (tid ))
@@ -159,17 +164,17 @@ int init_wdt_per_thread()
159164 return 1 ;
160165
161166 fail2 :
162- timer_delete (per_thread_wd_timer [tid ]);
167+ timer_delete (per_thread_wd_ctx [tid ]. timer );
163168 fail1 :
164- per_thread_wd_timer [tid ] = TIMER_INVALID ;
169+ per_thread_wd_ctx [tid ]. timer = TIMER_INVALID ;
165170 ha_warning ("Failed to setup watchdog timer for thread %u, disabling lockup detection.\n" , tid );
166171 return 1 ;
167172}
168173
169174void deinit_wdt_per_thread ()
170175{
171- if (per_thread_wd_timer [tid ] != TIMER_INVALID )
172- timer_delete (per_thread_wd_timer [tid ]);
176+ if (per_thread_wd_ctx [tid ]. timer != TIMER_INVALID )
177+ timer_delete (per_thread_wd_ctx [tid ]. timer );
173178}
174179
175180/* registers the watchdog signal handler and returns 0. This sets up the signal
0 commit comments