diff options
author | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-10-19 14:15:15 +0000 |
---|---|---|
committer | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-10-19 14:15:15 +0000 |
commit | 5dadb529d1957791b0125d38afebaeb53427fb8d (patch) | |
tree | 801e57fed074112458c77c12c8050255c41a44b2 /usr.sbin/hoststated | |
parent | 1919128b52ab85cdce80c42468da3dd2c2e24cc8 (diff) |
Move relays from static TAILQs to allocated ones.
This syncs it with other hoststated entities and will make reload easier.
This is step 1 out of 7 for reload.
Diffstat (limited to 'usr.sbin/hoststated')
-rw-r--r-- | usr.sbin/hoststated/hoststated.c | 13 | ||||
-rw-r--r-- | usr.sbin/hoststated/hoststated.h | 4 | ||||
-rw-r--r-- | usr.sbin/hoststated/parse.y | 13 | ||||
-rw-r--r-- | usr.sbin/hoststated/pfe.c | 4 | ||||
-rw-r--r-- | usr.sbin/hoststated/relay.c | 14 |
5 files changed, 25 insertions, 23 deletions
diff --git a/usr.sbin/hoststated/hoststated.c b/usr.sbin/hoststated/hoststated.c index b8774940c1f..ad9e9a3f7f8 100644 --- a/usr.sbin/hoststated/hoststated.c +++ b/usr.sbin/hoststated/hoststated.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hoststated.c,v 1.44 2007/10/12 12:50:59 blambert Exp $ */ +/* $OpenBSD: hoststated.c,v 1.45 2007/10/19 14:15:14 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -471,8 +471,8 @@ purge_config(struct hoststated *env, u_int8_t what) } if (what & PURGE_RELAYS) { - while ((rly = TAILQ_FIRST(&env->relays)) != NULL) { - TAILQ_REMOVE(&env->relays, rly, entry); + while ((rly = TAILQ_FIRST(env->relays)) != NULL) { + TAILQ_REMOVE(env->relays, rly, entry); while ((sess = SPLAY_ROOT(&rly->sessions)) != NULL) { SPLAY_REMOVE(session_tree, &rly->sessions, sess); @@ -486,6 +486,7 @@ purge_config(struct hoststated *env, u_int8_t what) SSL_CTX_free(rly->ssl_ctx); free(rly); } + free(env->relays); } if (what & PURGE_PROTOS) { @@ -733,7 +734,7 @@ relay_find(struct hoststated *env, objid_t id) { struct relay *rlay; - TAILQ_FOREACH(rlay, &env->relays, entry) + TAILQ_FOREACH(rlay, env->relays, entry) if (rlay->conf.id == id) return (rlay); return (NULL); @@ -745,7 +746,7 @@ session_find(struct hoststated *env, objid_t id) struct relay *rlay; struct session *con; - TAILQ_FOREACH(rlay, &env->relays, entry) + TAILQ_FOREACH(rlay, env->relays, entry) SPLAY_FOREACH(con, session_tree, &rlay->sessions) if (con->id == id) return (con); @@ -792,7 +793,7 @@ relay_findbyname(struct hoststated *env, const char *name) { struct relay *rlay; - TAILQ_FOREACH(rlay, &env->relays, entry) + TAILQ_FOREACH(rlay, env->relays, entry) if (strcmp(rlay->conf.name, name) == 0) return (rlay); return (NULL); diff --git a/usr.sbin/hoststated/hoststated.h b/usr.sbin/hoststated/hoststated.h index cc20e904474..2197cd61c70 100644 --- a/usr.sbin/hoststated/hoststated.h +++ b/usr.sbin/hoststated/hoststated.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hoststated.h,v 1.69 2007/10/19 12:08:55 pyr Exp $ */ +/* $OpenBSD: hoststated.h,v 1.70 2007/10/19 14:15:14 pyr Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -585,7 +585,7 @@ struct hoststated { struct tablelist *tables; struct servicelist *services; struct protolist protos; - struct relaylist relays; + struct relaylist *relays; u_int16_t prefork_relay; char demote_group[IFNAMSIZ]; u_int16_t id; diff --git a/usr.sbin/hoststated/parse.y b/usr.sbin/hoststated/parse.y index 460b6078446..3406b589e64 100644 --- a/usr.sbin/hoststated/parse.y +++ b/usr.sbin/hoststated/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.69 2007/10/19 09:08:05 pyr Exp $ */ +/* $OpenBSD: parse.y,v 1.70 2007/10/19 14:15:14 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -884,7 +884,7 @@ sslcache : NUMBER { relay : RELAY STRING { struct relay *r; - TAILQ_FOREACH(r, &conf->relays, entry) + TAILQ_FOREACH(r, conf->relays, entry) if (!strcmp(r->conf.name, $2)) break; if (r != NULL) { @@ -931,7 +931,7 @@ relay : RELAY STRING { } conf->relaycount++; SPLAY_INIT(&rlay->sessions); - TAILQ_INSERT_HEAD(&conf->relays, rlay, entry); + TAILQ_INSERT_HEAD(conf->relays, rlay, entry); } ; @@ -1580,6 +1580,7 @@ parse_config(const char *filename, int opts) if ((conf = calloc(1, sizeof(*conf))) == NULL || (conf->tables = calloc(1, sizeof(*conf->tables))) == NULL || + (conf->relays = calloc(1, sizeof(*conf->relays))) == NULL || (conf->services = calloc(1, sizeof(*conf->services))) == NULL) { log_warn("cannot allocate memory"); warn("cannot allocate memory"); @@ -1592,7 +1593,7 @@ parse_config(const char *filename, int opts) TAILQ_INIT(conf->services); TAILQ_INIT(conf->tables); TAILQ_INIT(&conf->protos); - TAILQ_INIT(&conf->relays); + TAILQ_INIT(conf->relays); memset(&conf->empty_table, 0, sizeof(conf->empty_table)); conf->empty_table.conf.id = EMPTY_TABLE; @@ -1645,12 +1646,12 @@ parse_config(const char *filename, int opts) } } - if (TAILQ_EMPTY(conf->services) && TAILQ_EMPTY(&conf->relays)) { + if (TAILQ_EMPTY(conf->services) && TAILQ_EMPTY(conf->relays)) { log_warnx("no services, nothing to do"); errors++; } - if (TAILQ_EMPTY(&conf->relays)) + if (TAILQ_EMPTY(conf->relays)) conf->prefork_relay = 0; if (timercmp(&conf->timeout, &conf->interval, >=)) { diff --git a/usr.sbin/hoststated/pfe.c b/usr.sbin/hoststated/pfe.c index 29451e4cdfe..e1df108a719 100644 --- a/usr.sbin/hoststated/pfe.c +++ b/usr.sbin/hoststated/pfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfe.c,v 1.37 2007/10/19 12:08:55 pyr Exp $ */ +/* $OpenBSD: pfe.c,v 1.38 2007/10/19 14:15:14 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -533,7 +533,7 @@ show(struct ctl_conn *c) imsg_compose(&c->ibuf, IMSG_CTL_HOST, 0, 0, -1, host, sizeof(*host)); } - TAILQ_FOREACH(rlay, &env->relays, entry) { + TAILQ_FOREACH(rlay, env->relays, entry) { rlay->stats[env->prefork_relay].id = EMPTY_ID; imsg_compose(&c->ibuf, IMSG_CTL_RELAY, 0, 0, -1, rlay, sizeof(*rlay)); diff --git a/usr.sbin/hoststated/relay.c b/usr.sbin/hoststated/relay.c index 2dfe205dcae..1ff02bfd089 100644 --- a/usr.sbin/hoststated/relay.c +++ b/usr.sbin/hoststated/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.50 2007/10/05 17:32:13 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.51 2007/10/19 14:15:14 pyr Exp $ */ /* * Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -260,7 +260,7 @@ relay_shutdown(void) struct session *con; struct relay *rlay; - TAILQ_FOREACH(rlay, &env->relays, entry) { + TAILQ_FOREACH(rlay, env->relays, entry) { if (rlay->conf.flags & F_DISABLE) continue; close(rlay->s); @@ -368,7 +368,7 @@ relay_privinit(void) if (env->flags & F_SSL) ssl_init(env); - TAILQ_FOREACH(rlay, &env->relays, entry) { + TAILQ_FOREACH(rlay, env->relays, entry) { log_debug("relay_init: adding relay %s", rlay->conf.name); if (debug) @@ -406,7 +406,7 @@ relay_init(void) struct host *host; struct timeval tv; - TAILQ_FOREACH(rlay, &env->relays, entry) { + TAILQ_FOREACH(rlay, env->relays, entry) { if ((rlay->conf.flags & F_SSL) && (rlay->ssl_ctx = relay_ssl_ctx_create(rlay)) == NULL) fatal("relay_init: failed to create SSL context"); @@ -462,7 +462,7 @@ relay_statistics(int fd, short events, void *arg) if (gettimeofday(&tv_now, NULL)) fatal("relay_init: gettimeofday"); - TAILQ_FOREACH(rlay, &env->relays, entry) { + TAILQ_FOREACH(rlay, env->relays, entry) { bzero(&crs, sizeof(crs)); resethour = resetday = 0; @@ -515,7 +515,7 @@ relay_launch(void) struct relay *rlay; void (*callback)(int, short, void *); - TAILQ_FOREACH(rlay, &env->relays, entry) { + TAILQ_FOREACH(rlay, env->relays, entry) { log_debug("relay_launch: running relay %s", rlay->conf.name); rlay->up = HOST_UP; @@ -1953,7 +1953,7 @@ relay_dispatch_pfe(int fd, short event, void *ptr) evtimer_add(&con->ev, &tv); break; case IMSG_CTL_SESSION: - TAILQ_FOREACH(rlay, &env->relays, entry) + TAILQ_FOREACH(rlay, env->relays, entry) SPLAY_FOREACH(con, session_tree, &rlay->sessions) imsg_compose(ibuf, IMSG_CTL_SESSION, |