Use the F_CHECK_SENT and F_CHECK_DONE flags to determine whether a
authorjmatthew <jmatthew@openbsd.org>
Mon, 22 Feb 2021 01:24:59 +0000 (01:24 +0000)
committerjmatthew <jmatthew@openbsd.org>
Mon, 22 Feb 2021 01:24:59 +0000 (01:24 +0000)
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
usr.sbin/relayd/hce.c

index cf51a83..d0cd1f6 100644 (file)
@@ -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 <reyk@openbsd.org>
@@ -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
index 8fb7701..f1a5082 100644 (file)
@@ -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 <pyr@openbsd.org>
@@ -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);