/*
SSSD
Timer Watchdog routines
Copyright (C) Simo Sorce 2016
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <signal.h>
/* this is intentionally a global variable */
struct watchdog_ctx {
volatile int ticks;
/* To detect time shift. */
int input_interval;
} watchdog_ctx;
static void watchdog_detect_timeshift(void)
{
/* Time shift detected. We need to restart watchdog. */
} else {
_exit(1);
}
}
}
}
/* the watchdog is purposefully *not* handled by the tevent
* signal handler as it is meant to check if the daemon is
* still processing the event queue itself. A stuck process
* may not handle the event queue at all and thus not handle
* signals either */
{
/* if a pre-defined number of ticks passed by kills itself */
} else {
_exit(1);
}
}
}
static void watchdog_reset(void)
{
}
struct tevent_timer *te,
struct timeval current_time,
void *private_data)
{
/* first thing reset the watchdog ticks */
/* then set a new watchodg event */
/* if the function fails the watchdog will kill the
* process soon enough, so we just warn */
if (!watchdog_ctx.te) {
"Failed to create a watchdog timer event!\n");
}
}
{
errno = 0;
if (len == -1) {
return EAGAIN;
} else {
return ret;
}
}
return EOK;
}
void *data)
{
switch(ret) {
case EAGAIN:
"Interrupted before any data could be read, retry later.\n");
return;
case EOK:
/* all fine */
break;
default:
"Failed to receive data [%d]: %s. "
orderly_shutdown(1);
}
"restarting watchdog!\n");
orderly_shutdown(1);
}
}
}
{
int ret;
errno = 0;
if (ret == -1) {
"Failed to create watchdog timer (%d) [%s]\n",
return ret;
}
if (interval == 0) {
}
if (ret == -1) {
return ret;
}
/* Start the timer */
/* we give 1 second head start to the watchdog event */
errno = 0;
if (ret == -1) {
"Failed to create watchdog timer (%d) [%s]\n",
return ret;
}
/* Add the watchdog event and make it fire as fast as the timer */
return EOK;
}
void teardown_watchdog(void)
{
int ret;
/* Disarm the timer */
errno = 0;
if (ret == -1) {
"Failed to destroy watchdog timer (%d) [%s]\n",
}
/* Free the tevent_fd */
/* Close the pipefds */
/* and kill the watchdog event */
}