diff options
author | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-05-30 00:12:22 +0000 |
---|---|---|
committer | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-05-30 00:12:22 +0000 |
commit | 4b4c0084cf4e0d79a23e5a07198c8fdf05736ea2 (patch) | |
tree | 0a37877f0822cb999765b8498f7b9795fe95b98d /usr.sbin/hoststated | |
parent | fc62075b6cd19357c3761131439fbdf8215ae515 (diff) |
backout last diff which introduces problems and use the global
environment instead.
Diffstat (limited to 'usr.sbin/hoststated')
-rw-r--r-- | usr.sbin/hoststated/hoststated.c | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/usr.sbin/hoststated/hoststated.c b/usr.sbin/hoststated/hoststated.c index d886d8b8ce0..ee9a592b7d3 100644 --- a/usr.sbin/hoststated/hoststated.c +++ b/usr.sbin/hoststated/hoststated.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hoststated.c,v 1.30 2007/05/29 23:58:30 pyr Exp $ */ +/* $OpenBSD: hoststated.c,v 1.31 2007/05/30 00:12:21 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -47,6 +47,7 @@ void main_dispatch_relay(int, short, void *); int check_child(pid_t, const char *); int send_all(struct hoststated *, enum imsg_type, void *, u_int16_t); +void reconfigure(struct hoststated *); int pipe_parent2pfe[2]; int pipe_parent2hce[2]; @@ -339,6 +340,44 @@ send_all(struct hoststated *env, enum imsg_type type, void *buf, u_int16_t len) } void +reconfigure(struct hoststated *env) +{ + struct hoststated *new_env; + struct table *table; + struct host *host; + struct service *service; + struct address *virt; + + if ((new_env = parse_config(env->confpath, env->opts)) == NULL) + fatalx("reconfigure: could not parse configuration"); + log_warnx("PURGING CONF"); + purge_config(env, PURGE_EVERYTHING); + log_warnx("MEMCPY ENV"); + memcpy(env, new_env, sizeof(*env)); + /* + * XXX free(new_env) + */ + TAILQ_FOREACH(table, &env->tables, entry) { + send_all(env, IMSG_RECONF_TABLE, + &table->conf, sizeof(table->conf)); + imsg_compose(ibuf_hce, IMSG_RECONF_SENDBUF, 0, 0, + table->sendbuf, strlen(table->sendbuf)); + TAILQ_FOREACH(host, &table->hosts, entry) + send_all(env, IMSG_RECONF_HOST, + &host->conf, sizeof(host->conf)); + } + TAILQ_FOREACH(service, &env->services, entry) { + imsg_compose(ibuf_pfe, IMSG_RECONF_SERVICE, 0, 0, + &service->conf, sizeof(service->conf)); + TAILQ_FOREACH(virt, &service->virts, entry) + imsg_compose(ibuf_pfe, IMSG_RECONF_VIRT, 0, 0, + virt, sizeof(*virt)); + } + + send_all(env, IMSG_RECONF_END, NULL, 0); +} + +void purge_config(struct hoststated *env, u_int8_t what) { struct table *table; @@ -442,7 +481,6 @@ main_dispatch_pfe(int fd, short event, void *ptr) struct imsg imsg; ssize_t n; struct ctl_demote demote; - struct hoststated *env = ptr; ibuf = ptr; switch (event) { @@ -480,6 +518,7 @@ main_dispatch_pfe(int fd, short event, void *ptr) /* * so far we only get here if no L7 (relay) is done. */ + reconfigure(env); break; default: log_debug("main_dispatch_pfe: unexpected imsg %d", @@ -498,7 +537,7 @@ main_dispatch_hce(int fd, short event, void * ptr) struct imsg imsg; ssize_t n; struct ctl_script scr; - struct hoststated *env = ptr; + struct hoststated *env; env = hoststated_env; ibuf = ptr; @@ -551,7 +590,6 @@ main_dispatch_relay(int fd, short event, void * ptr) struct imsgbuf *ibuf; struct imsg imsg; ssize_t n; - struct hoststated *env = ptr; ibuf = ptr; switch (event) { |