diff options
author | 2019-06-14 19:55:25 +0000 | |
---|---|---|
committer | 2019-06-14 19:55:25 +0000 | |
commit | 28efdb08be427ae93da8928ad7bb57bc16cc92d6 (patch) | |
tree | fc91611f3e39e26e22699d4ebebdde2642b50a82 /usr.sbin/smtpd/mta.c | |
parent | Track key type (RSA or ECDSA) in an enum and clean up a bit while here. (diff) | |
download | wireguard-openbsd-28efdb08be427ae93da8928ad7bb57bc16cc92d6.tar.xz wireguard-openbsd-28efdb08be427ae93da8928ad7bb57bc16cc92d6.zip |
simplify the runq interface:
- remove (unused) per-job callback
- rename runq_schedule() to runq_schedule_at() and runq_delay()
to runq_schedule()
- remove unused runq_next()
ok sunil@ gilles@
Diffstat (limited to 'usr.sbin/smtpd/mta.c')
-rw-r--r-- | usr.sbin/smtpd/mta.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c index 6958384a115..76e0be8e86c 100644 --- a/usr.sbin/smtpd/mta.c +++ b/usr.sbin/smtpd/mta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta.c,v 1.227 2018/12/23 16:37:53 eric Exp $ */ +/* $OpenBSD: mta.c,v 1.228 2019/06/14 19:55:25 eric Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -326,7 +326,7 @@ mta_imsg(struct mproc *p, struct imsg *imsg) if (route->flags & ROUTE_DISABLED) { log_info("smtp-out: Enabling route %s per admin request", mta_route_to_text(route)); - if (!runq_cancel(runq_route, NULL, route)) { + if (!runq_cancel(runq_route, route)) { log_warnx("warn: route not on runq"); fatalx("exiting"); } @@ -370,7 +370,7 @@ mta_imsg(struct mproc *p, struct imsg *imsg) case IMSG_CTL_MTA_SHOW_ROUTES: SPLAY_FOREACH(route, mta_route_tree, &routes) { - v = runq_pending(runq_route, NULL, route, &t); + v = runq_pending(runq_route, route, &t); (void)snprintf(buf, sizeof(buf), "%llu. %s %c%c%c%c nconn=%zu nerror=%d penalty=%d timeout=%s", (unsigned long long)route->id, @@ -1165,7 +1165,7 @@ mta_connect(struct mta_connector *c) if (c->flags & CONNECTOR_WAIT) { log_debug("debug: mta: cancelling connector timeout"); - runq_cancel(runq_connector, NULL, c); + runq_cancel(runq_connector, c); c->flags &= ~CONNECTOR_WAIT; } @@ -1257,7 +1257,7 @@ mta_connect(struct mta_connector *c) mta_connector_to_text(c), (unsigned long long) nextconn - time(NULL)); c->flags |= CONNECTOR_WAIT; - runq_schedule(runq_connector, nextconn, NULL, c); + runq_schedule_at(runq_connector, nextconn, c); return; } @@ -1336,12 +1336,12 @@ mta_route_disable(struct mta_route *route, int penalty, int reason) mta_route_to_text(route), delay); if (route->flags & ROUTE_DISABLED) - runq_cancel(runq_route, NULL, route); + runq_cancel(runq_route, route); else mta_route_ref(route); route->flags |= reason & ROUTE_DISABLED; - runq_schedule(runq_route, time(NULL) + delay, NULL, route); + runq_schedule(runq_route, delay, route); } static void @@ -1434,7 +1434,7 @@ mta_drain(struct mta_relay *r) log_debug("debug: mta: scheduling relay %s in %llus...", mta_relay_to_text(r), (unsigned long long) r->nextsource - time(NULL)); - runq_schedule(runq_relay, r->nextsource, NULL, r); + runq_schedule_at(runq_relay, r->nextsource, r); r->status |= RELAY_WAIT_CONNECTOR; mta_relay_ref(r); } @@ -1938,7 +1938,7 @@ mta_relay_show(struct mta_relay *r, struct mproc *p, uint32_t id, time_t t) SHOWSTATUS(RELAY_WAIT_CONNECTOR, "connector"); #undef SHOWSTATUS - if (runq_pending(runq_relay, NULL, r, &to)) + if (runq_pending(runq_relay, r, &to)) (void)snprintf(dur, sizeof(dur), "%s", duration_to_text(to - t)); else (void)strlcpy(dur, "-", sizeof(dur)); @@ -1957,7 +1957,7 @@ mta_relay_show(struct mta_relay *r, struct mproc *p, uint32_t id, time_t t) iter = NULL; while (tree_iter(&r->connectors, &iter, NULL, (void **)&c)) { - if (runq_pending(runq_connector, NULL, c, &to)) + if (runq_pending(runq_connector, c, &to)) (void)snprintf(dur, sizeof(dur), "%s", duration_to_text(to - t)); else (void)strlcpy(dur, "-", sizeof(dur)); @@ -2306,7 +2306,7 @@ mta_connector_free(struct mta_connector *c) if (c->flags & CONNECTOR_WAIT) { log_debug("debug: mta: cancelling timeout for %s", mta_connector_to_text(c)); - runq_cancel(runq_connector, NULL, c); + runq_cancel(runq_connector, c); } mta_source_unref(c->source); /* from constructor */ free(c); @@ -2351,7 +2351,7 @@ mta_route(struct mta_source *src, struct mta_host *dst) log_debug("debug: mta: mta_route_ref(): cancelling runq for route %s", mta_route_to_text(r)); r->flags &= ~(ROUTE_RUNQ | ROUTE_KEEPALIVE); - runq_cancel(runq_route, NULL, r); + runq_cancel(runq_route, r); r->refcount--; /* from mta_route_unref() */ } @@ -2406,7 +2406,7 @@ mta_route_unref(struct mta_route *r) if (sched > now) { r->flags |= ROUTE_RUNQ; - runq_schedule(runq_route, sched, NULL, r); + runq_schedule_at(runq_route, sched, r); r->refcount++; return; } @@ -2531,26 +2531,24 @@ mta_hoststat_update(const char *host, const char *error) { struct hoststat *hs = NULL; char buf[HOST_NAME_MAX+1]; - time_t tm; if (!lowercase(buf, host, sizeof buf)) return; - tm = time(NULL); hs = dict_get(&hoststat, buf); if (hs == NULL) { if ((hs = calloc(1, sizeof *hs)) == NULL) return; tree_init(&hs->deferred); - runq_schedule(runq_hoststat, tm+HOSTSTAT_EXPIRE_DELAY, NULL, hs); + runq_schedule(runq_hoststat, HOSTSTAT_EXPIRE_DELAY, hs); } (void)strlcpy(hs->name, buf, sizeof hs->name); (void)strlcpy(hs->error, error, sizeof hs->error); hs->tm = time(NULL); dict_set(&hoststat, buf, hs); - runq_cancel(runq_hoststat, NULL, hs); - runq_schedule(runq_hoststat, tm+HOSTSTAT_EXPIRE_DELAY, NULL, hs); + runq_cancel(runq_hoststat, hs); + runq_schedule(runq_hoststat, HOSTSTAT_EXPIRE_DELAY, hs); } void @@ -2614,5 +2612,5 @@ mta_hoststat_remove_entry(struct hoststat *hs) while (tree_poproot(&hs->deferred, NULL, NULL)) ; dict_pop(&hoststat, hs->name); - runq_cancel(runq_hoststat, NULL, hs); + runq_cancel(runq_hoststat, hs); } |