From 19a6b45e5e01389b17e47c63c256aec4fbbc7ff9 Mon Sep 17 00:00:00 2001 From: jmatthew Date: Mon, 22 Feb 2021 01:24:59 +0000 Subject: [PATCH] Use the F_CHECK_SENT and F_CHECK_DONE flags to determine whether a previous attempt at running a check script has finished yet, so we can avoid building up a backlog of check requests. ok dlg@ tb@ giovanni@ --- usr.sbin/relayd/check_script.c | 9 +++++++-- usr.sbin/relayd/hce.c | 3 +-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/usr.sbin/relayd/check_script.c b/usr.sbin/relayd/check_script.c index cf51a835c8f..d0cd1f6fc7f 100644 --- a/usr.sbin/relayd/check_script.c +++ b/usr.sbin/relayd/check_script.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check_script.c,v 1.21 2017/05/28 10:39:15 benno Exp $ */ +/* $OpenBSD: check_script.c,v 1.22 2021/02/22 01:24:59 jmatthew Exp $ */ /* * Copyright (c) 2007 - 2014 Reyk Floeter @@ -38,6 +38,9 @@ check_script(struct relayd *env, struct host *host) struct ctl_script scr; struct table *table; + if ((host->flags & (F_CHECK_SENT|F_CHECK_DONE)) == F_CHECK_SENT) + return; + if ((table = table_find(env, host->conf.tableid)) == NULL) fatalx("%s: invalid table id", __func__); @@ -52,7 +55,9 @@ check_script(struct relayd *env, struct host *host) fatalx("invalid script path"); memcpy(&scr.timeout, &table->conf.timeout, sizeof(scr.timeout)); - proc_compose(env->sc_ps, PROC_PARENT, IMSG_SCRIPT, &scr, sizeof(scr)); + if (proc_compose(env->sc_ps, PROC_PARENT, IMSG_SCRIPT, &scr, + sizeof(scr)) == 0) + host->flags |= F_CHECK_SENT; } void diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c index 8fb7701d047..f1a5082504b 100644 --- a/usr.sbin/relayd/hce.c +++ b/usr.sbin/relayd/hce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hce.c,v 1.79 2018/08/06 17:31:31 benno Exp $ */ +/* $OpenBSD: hce.c,v 1.80 2021/02/22 01:24:59 jmatthew Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard @@ -139,7 +139,6 @@ hce_launch_checks(int fd, short event, void *arg) TAILQ_FOREACH(host, &table->hosts, entry) { if ((host->flags & F_CHECK_DONE) == 0) host->he = HCE_INTERVAL_TIMEOUT; - host->flags &= ~(F_CHECK_SENT|F_CHECK_DONE); if (event_initialized(&host->cte.ev)) { event_del(&host->cte.ev); close(host->cte.s); -- 2.20.1