Enable the software watchdog with the specified period in milliseconds. */
| 2172 | |
| 2173 | /* Enable the software watchdog with the specified period in milliseconds. */ |
| 2174 | void enableWatchdog(int period) { |
| 2175 | int min_period; |
| 2176 | |
| 2177 | if (g_pserver->watchdog_period == 0) { |
| 2178 | struct sigaction act; |
| 2179 | |
| 2180 | /* Watchdog was actually disabled, so we have to setup the signal |
| 2181 | * handler. */ |
| 2182 | sigemptyset(&act.sa_mask); |
| 2183 | act.sa_flags = SA_SIGINFO; |
| 2184 | act.sa_sigaction = watchdogSignalHandler; |
| 2185 | sigaction(SIGALRM, &act, NULL); |
| 2186 | } |
| 2187 | /* If the configured period is smaller than twice the timer period, it is |
| 2188 | * too short for the software watchdog to work reliably. Fix it now |
| 2189 | * if needed. */ |
| 2190 | min_period = (1000/g_pserver->hz)*2; |
| 2191 | if (period < min_period) period = min_period; |
| 2192 | watchdogScheduleSignal(period); /* Adjust the current timer. */ |
| 2193 | g_pserver->watchdog_period = period; |
| 2194 | } |
| 2195 | |
| 2196 | /* Disable the software watchdog. */ |
| 2197 | void disableWatchdog(void) { |
no test coverage detected