Enable the software watchdog with the specified period in milliseconds. */
| 1942 | |
| 1943 | /* Enable the software watchdog with the specified period in milliseconds. */ |
| 1944 | void enableWatchdog(int period) { |
| 1945 | int min_period; |
| 1946 | |
| 1947 | if (server.watchdog_period == 0) { |
| 1948 | struct sigaction act; |
| 1949 | |
| 1950 | /* Watchdog was actually disabled, so we have to setup the signal |
| 1951 | * handler. */ |
| 1952 | sigemptyset(&act.sa_mask); |
| 1953 | act.sa_flags = SA_SIGINFO; |
| 1954 | act.sa_sigaction = watchdogSignalHandler; |
| 1955 | sigaction(SIGALRM, &act, NULL); |
| 1956 | } |
| 1957 | /* If the configured period is smaller than twice the timer period, it is |
| 1958 | * too short for the software watchdog to work reliably. Fix it now |
| 1959 | * if needed. */ |
| 1960 | min_period = (1000/server.hz)*2; |
| 1961 | if (period < min_period) period = min_period; |
| 1962 | watchdogScheduleSignal(period); /* Adjust the current timer. */ |
| 1963 | server.watchdog_period = period; |
| 1964 | } |
| 1965 | |
| 1966 | /* Disable the software watchdog. */ |
| 1967 | void disableWatchdog(void) { |
no test coverage detected