From 1919128b52ab85cdce80c42468da3dd2c2e24cc8 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Ritschard Date: Fri, 19 Oct 2007 12:08:56 +0000 Subject: Add the ability to schedule an immediate check through hoststatectl. Especially useful when interval is rather long. I was supposed to commit this before 4.2. --- usr.sbin/relayd/control.c | 13 ++++++++++--- usr.sbin/relayd/hce.c | 6 +++++- usr.sbin/relayd/pfe.c | 4 ++-- usr.sbin/relayd/relayd.h | 5 +++-- 4 files changed, 20 insertions(+), 8 deletions(-) (limited to 'usr.sbin/relayd') diff --git a/usr.sbin/relayd/control.c b/usr.sbin/relayd/control.c index 08094fe9547..5ea9d46fb02 100644 --- a/usr.sbin/relayd/control.c +++ b/usr.sbin/relayd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.18 2007/09/07 08:20:24 reyk Exp $ */ +/* $OpenBSD: control.c,v 1.19 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -43,6 +43,7 @@ struct ctl_conn *control_connbyfd(int); void control_close(int); struct imsgbuf *ibuf_main = NULL; +struct imsgbuf *ibuf_hce = NULL; int control_init(void) @@ -94,10 +95,12 @@ control_init(void) } int -control_listen(struct hoststated *env, struct imsgbuf *ibuf) +control_listen(struct hoststated *env, struct imsgbuf *i_main, + struct imsgbuf *i_hce) { - ibuf_main = ibuf; + ibuf_main = i_main; + ibuf_hce = i_hce; if (listen(control_state.fd, CONTROL_BACKLOG) == -1) { log_warn("control_listen: listen"); @@ -316,6 +319,10 @@ control_dispatch_imsg(int fd, short event, void *arg) imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1, NULL, 0); break; + case IMSG_CTL_POLL: + imsg_compose(ibuf_hce, IMSG_CTL_POLL, 0, 0,-1, NULL, 0); + imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1, NULL, 0); + break; case IMSG_CTL_RELOAD: if (env->prefork_relay > 0) { imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1, diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c index 2c01db611bf..62a34e8b6e4 100644 --- a/usr.sbin/relayd/hce.c +++ b/usr.sbin/relayd/hce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hce.c,v 1.31 2007/10/12 12:50:59 blambert Exp $ */ +/* $OpenBSD: hce.c,v 1.32 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard @@ -395,6 +395,10 @@ hce_dispatch_imsg(int fd, short event, void *ptr) TAILQ_FOREACH(host, &table->hosts, entry) host->up = HOST_UNKNOWN; break; + case IMSG_CTL_POLL: + evtimer_del(&env->ev); + hce_launch_checks(-1, EV_TIMEOUT, env); + break; default: log_debug("hce_dispatch_msg: unexpected imsg %d", imsg.hdr.type); diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c index 6b27a81df4f..29451e4cdfe 100644 --- a/usr.sbin/relayd/pfe.c +++ b/usr.sbin/relayd/pfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfe.c,v 1.36 2007/09/28 13:29:56 pyr Exp $ */ +/* $OpenBSD: pfe.c,v 1.37 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard @@ -156,7 +156,7 @@ pfe(struct hoststated *x_env, int pipe_parent2pfe[2], int pipe_parent2hce[2], TAILQ_INIT(&ctl_conns); - if (control_listen(env, ibuf_main) == -1) + if (control_listen(env, ibuf_main, ibuf_hce) == -1) fatalx("pfe: control socket listen failed"); /* Initial sync */ diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index 35a8c9840ce..cdb4b501699 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.68 2007/10/12 12:50:59 blambert Exp $ */ +/* $OpenBSD: relayd.h,v 1.69 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard @@ -118,6 +118,7 @@ enum imsg_type { IMSG_CTL_HOST_DISABLE, IMSG_CTL_SHUTDOWN, IMSG_CTL_RELOAD, + IMSG_CTL_POLL, IMSG_CTL_NOTIFY, IMSG_CTL_STATISTICS, IMSG_SERVICE_ENABLE, /* notifies from pfe to hce */ @@ -628,7 +629,7 @@ TAILQ_HEAD(ctl_connlist, ctl_conn); /* control.c */ int control_init(void); -int control_listen(struct hoststated *, struct imsgbuf *); +int control_listen(struct hoststated *, struct imsgbuf *, struct imsgbuf *); void control_accept(int, short, void *); void control_dispatch_imsg(int, short, void *); void control_imsg_forward(struct imsg *); -- cgit v1.2.3