bool unregister_watchdog(watchdog_t *wd) { watchdog_t *p; bool ok = false; if (!wd_is_init) { Jmsg0(NULL, M_ABORT, 0, _("BUG! unregister_watchdog_unlocked called before start_watchdog\n")); } wd_lock(); foreach_dlist(p, wd_queue) { if (wd == p) { wd_queue->remove(wd); Dmsg1(800, "Unregistered watchdog %p\n", wd); ok = true; goto get_out; } } foreach_dlist(p, wd_inactive) { if (wd == p) { wd_inactive->remove(wd); Dmsg1(800, "Unregistered inactive watchdog %p\n", wd); ok = true; goto get_out; } } Dmsg1(800, "Failed to unregister watchdog %p\n", wd); get_out: wd_unlock(); ping_watchdog(); return ok; }
static ssize_t harddog_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) { if(len) return ping_watchdog(harddog_out_fd); return 0; }
static ssize_t harddog_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) { /* * Refresh the timer. */ if(len) return(ping_watchdog(harddog_out_fd)); return 0; }
/* * Terminate the watchdog thread * * Returns: 0 on success * errno on failure */ int stop_watchdog(void) { int stat; watchdog_t *p; if (!wd_is_init) { return 0; } quit = true; /* notify watchdog thread to stop */ ping_watchdog(); stat = pthread_join(wd_tid, NULL); while (!wd_queue->empty()) { void *item = wd_queue->first(); wd_queue->remove(item); p = (watchdog_t *)item; if (p->destructor != NULL) { p->destructor(p); } free(p); } delete wd_queue; wd_queue = NULL; while (!wd_inactive->empty()) { void *item = wd_inactive->first(); wd_inactive->remove(item); p = (watchdog_t *)item; if (p->destructor != NULL) { p->destructor(p); } free(p); } delete wd_inactive; wd_inactive = NULL; rwl_destroy(&lock); wd_is_init = false; return stat; }
bool register_watchdog(watchdog_t *wd) { if (!wd_is_init) { Jmsg0(NULL, M_ABORT, 0, _("BUG! register_watchdog called before start_watchdog\n")); } if (wd->callback == NULL) { Jmsg1(NULL, M_ABORT, 0, _("BUG! Watchdog %p has NULL callback\n"), wd); } if (wd->interval == 0) { Jmsg1(NULL, M_ABORT, 0, _("BUG! Watchdog %p has zero interval\n"), wd); } wd_lock(); wd->next_fire = watchdog_time + wd->interval; wd_queue->append(wd); Dmsg3(800, "Registered watchdog %p, interval %d%s\n", wd, wd->interval, wd->one_shot ? " one shot" : ""); wd_unlock(); ping_watchdog(); return false; }
static int harddog_ioctl_unlocked(struct file *file, unsigned int cmd, unsigned long arg) { void __user *argp= (void __user *)arg; static struct watchdog_info ident = { WDIOC_SETTIMEOUT, 0, "UML Hardware Watchdog" }; switch (cmd) { default: return -ENOTTY; case WDIOC_GETSUPPORT: if(copy_to_user(argp, &ident, sizeof(ident))) return -EFAULT; return 0; case WDIOC_GETSTATUS: case WDIOC_GETBOOTSTATUS: return put_user(0,(int __user *)argp); case WDIOC_KEEPALIVE: return ping_watchdog(harddog_out_fd); } }