/* Static globals */
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t timer = PTHREAD_COND_INITIALIZER;
-static int quit;
+static bool quit;
static bool wd_is_init = false;
/* Forward referenced callback functions */
-static void callback_child_timer(watchdog_t *self);
-static void callback_thread_timer(watchdog_t *self);
static pthread_t wd_tid;
/* Static globals */
Dmsg0(200, "Initialising NicB-hacked watchdog thread\n");
watchdog_time = time(NULL);
- quit = FALSE;
+ quit = false;
if ((stat = pthread_create(&wd_tid, NULL, watchdog_thread, NULL)) != 0) {
return stat;
}
watchdog_t *p, *n;
if (!wd_is_init) {
- Emsg0(M_ABORT, 0, "BUG! stop_watchdog called before start_watchdog\n");
+ return 0;
}
Dmsg0(200, "Sending stop signal to NicB-hacked watchdog thread\n");
wd->next_fire = watchdog_time + wd->interval;
TAILQ_INSERT_TAIL(&wd_queue, wd, qe);
Dmsg3(200, "Registered watchdog %p, interval %d%s\n",
- wd, wd->interval, wd->one_shot ? " one shot" : "");
+ wd, wd->interval, wd->one_shot ? " one shot" : "");
V(mutex);
return false;
TAILQ_FOREACH_SAFE(p, &wd_queue, qe, n) {
if (wd == p) {
TAILQ_REMOVE(&wd_queue, wd, qe);
- Dmsg1(200, "Unregistered watchdog %p\n", wd);
+ Dmsg1(200, "Unregistered watchdog %p\n", wd);
return true;
}
}
TAILQ_FOREACH_SAFE(p, &wd_inactive, qe, n) {
if (wd == p) {
TAILQ_REMOVE(&wd_inactive, wd, qe);
- Dmsg1(200, "Unregistered inactive watchdog %p\n", wd);
+ Dmsg1(200, "Unregistered inactive watchdog %p\n", wd);
return true;
}
}
/* Run the callback */
p->callback(p);
- /* Reschedule (or move to inactive list if it's a one-shot timer) */
+ /* Reschedule (or move to inactive list if it's a one-shot timer) */
if (p->one_shot) {
TAILQ_REMOVE(&wd_queue, p, qe);
TAILQ_INSERT_TAIL(&wd_inactive, p, qe);