Commit Diff


commit - d273c0648d7bb1245d43d8d34ff75b62270155e2
commit + e45334e6ae0b658a2d3d4f47bc3e9ddfdb83a44f
blob - a034a275edc32373952e64f67b8064f98def684b
blob + 5c38d746a682d6e1236ba2f29690b65d0e0e0016
--- config.c
+++ config.c
@@ -30,9 +30,8 @@ config_init(void)
 {
 	memset(&conf, 0, sizeof(conf));
 
-	TAILQ_INIT(&hosts);
-
 	TAILQ_INIT(&conf.fcgi);
+	TAILQ_INIT(&conf.hosts);
 
 	conf.port = 1965;
 	conf.ipv6 = 0;
@@ -74,15 +73,8 @@ config_free(void)
 		TAILQ_REMOVE(&conf.fcgi, f, fcgi);
 		free(f);
 	}
-	memset(&conf, 0, sizeof(conf));
 
-	conf.ps = ps;
-	conf.sock4 = conf.sock6 = -1;
-	conf.protos = TLS_PROTOCOL_TLSv1_2 | TLS_PROTOCOL_TLSv1_3;
-	init_mime(&conf.mime);
-	TAILQ_INIT(&conf.fcgi);
-
-	TAILQ_FOREACH_SAFE(h, &hosts, vhosts, th) {
+	TAILQ_FOREACH_SAFE(h, &conf.hosts, vhosts, th) {
 		free(h->cert_path);
 		free(h->key_path);
 		free(h->ocsp_path);
@@ -122,9 +114,18 @@ config_free(void)
 			free(p);
 		}
 
-		TAILQ_REMOVE(&hosts, h, vhosts);
+		TAILQ_REMOVE(&conf.hosts, h, vhosts);
 		free(h);
 	}
+
+	memset(&conf, 0, sizeof(conf));
+
+	conf.ps = ps;
+	conf.sock4 = conf.sock6 = -1;
+	conf.protos = TLS_PROTOCOL_TLSv1_2 | TLS_PROTOCOL_TLSv1_3;
+	init_mime(&conf.mime);
+	TAILQ_INIT(&conf.fcgi);
+	TAILQ_INIT(&conf.hosts);
 }
 
 static int
@@ -242,7 +243,7 @@ config_send_socks(struct conf *conf)
 }
 
 int
-config_send(struct conf *conf, struct vhosthead *hosts)
+config_send(struct conf *conf)
 {
 	struct privsep	*ps = conf->ps;
 	struct etm	*m;
@@ -286,7 +287,7 @@ config_send(struct conf *conf, struct vhosthead *hosts
 			return -1;
 	}
 
-	TAILQ_FOREACH(h, hosts, vhosts) {
+	TAILQ_FOREACH(h, &conf->hosts, vhosts) {
 		struct vhost vcopy;
 
 		memcpy(&vcopy, h, sizeof(vcopy));
@@ -520,7 +521,7 @@ config_recv(struct conf *conf, struct imsg *imsg)
 		vh = new_vhost();
 		strlcpy(vh->domain, vht.domain, sizeof(vh->domain));
 		h = vh;
-		TAILQ_INSERT_TAIL(&hosts, h, vhosts);
+		TAILQ_INSERT_TAIL(&conf->hosts, h, vhosts);
 
 		/* reset proxy */
 		p = NULL;
blob - 63065aa618e8a098ed498501d0cd387ca342ec1b
blob + 47ed883805ee02ede1a49148a7c24de2765bc410
--- ge.c
+++ ge.c
@@ -33,8 +33,6 @@
 
 struct conf conf;
 int privsep_process;
-
-struct vhosthead hosts = TAILQ_HEAD_INITIALIZER(hosts);
 
 static const struct option opts[] = {
 	{"help",	no_argument,	NULL,	'h'},
@@ -290,7 +288,7 @@ main(int argc, char **argv)
 
 	/* set up the implicit vhost and location */
 	host = xcalloc(1, sizeof(*host));
-	TAILQ_INSERT_HEAD(&hosts, host, vhosts);
+	TAILQ_INSERT_HEAD(&conf.hosts, host, vhosts);
 
 	loc = xcalloc(1, sizeof(*loc));
 	loc->fcgi = -1;
blob - 11aaec404f67102274e360377ac50b0f7323fbc1
blob + 7a7a47d59153945a0f83db89e815b90bdcf2b801
--- gmid.c
+++ gmid.c
@@ -57,8 +57,6 @@ static const struct option longopts[] = {
 	{"version",	no_argument,		NULL,	'V'},
 	{NULL,		0,			NULL,	0},
 };
-
-struct vhosthead hosts;
 
 int sock4, sock6;
 int privsep_process;
@@ -314,7 +312,7 @@ main_configure(struct conf *conf)
 	if (proc_compose(ps, PROC_SERVER, IMSG_RECONF_START, NULL, 0) == -1)
 		return -1;
 
-	if (config_send(conf, &hosts) == -1)
+	if (config_send(conf) == -1)
 		return -1;
 
 	if (proc_compose(ps, PROC_SERVER, IMSG_RECONF_END, NULL, 0) == -1)
blob - fc64880a13d8d8fb58c39b15f18c7ee6fa17fc94
blob + 20e20561ad8897f10d46b36c5dc54841afa437e0
--- gmid.h
+++ gmid.h
@@ -168,7 +168,7 @@ struct alist {
 	TAILQ_ENTRY(alist) aliases;
 };
 
-extern TAILQ_HEAD(vhosthead, vhost) hosts;
+TAILQ_HEAD(vhosthead, vhost);
 struct vhost {
 	char		 domain[HOST_NAME_MAX + 1];
 	char		*cert_path;
@@ -226,6 +226,7 @@ struct conf {
 	struct event	 evsock6;
 
 	struct fcgihead	 fcgi;
+	struct vhosthead hosts;
 };
 
 extern const char *config_path;
@@ -340,7 +341,7 @@ void		 log_request(struct client *, char *, size_t);
 /* config.c */
 void		 config_init(void);
 void		 config_free(void);
-int		 config_send(struct conf *, struct vhosthead *);
+int		 config_send(struct conf *);
 int		 config_recv(struct conf *, struct imsg *);
 
 /* parse.y */
blob - fb88fcac5af5df99b46d30ed604da028ecb28065
blob + d4ac93a011e898d39a759ea126c85333b8b9368d
--- parse.y
+++ parse.y
@@ -237,7 +237,7 @@ option		: CHROOT string	{
 
 vhost		: SERVER string {
 			host = new_vhost();
-			TAILQ_INSERT_HEAD(&hosts, host, vhosts);
+			TAILQ_INSERT_HEAD(&conf.hosts, host, vhosts);
 
 			loc = new_location();
 			TAILQ_INSERT_HEAD(&host->locations, loc, locations);
@@ -953,7 +953,7 @@ print_conf(void)
 	if (*conf.user != '\0')
 		printf("user \"%s\"\n", conf.user);
 
-	TAILQ_FOREACH(h, &hosts, vhosts) {
+	TAILQ_FOREACH(h, &conf.hosts, vhosts) {
 		printf("\nserver \"%s\" {\n", h->domain);
 		printf("	cert \"%s\"\n", h->cert);
 		printf("	key \"%s\"\n", h->key);
blob - 80f8d25cfb68c2b6d2cab4e4cc8031d3b955052e
blob + dd7dcc875e069678853006010393e58f52d7e815
--- server.c
+++ server.c
@@ -433,7 +433,7 @@ handle_handshake(int fd, short ev, void *d)
 		goto err;
 	}
 
-	TAILQ_FOREACH(h, &hosts, vhosts) {
+	TAILQ_FOREACH(h, &conf.hosts, vhosts) {
 		if (matches(h->domain, c->domain))
 			goto found;
 		TAILQ_FOREACH(a, &h->aliases, aliases) {
@@ -1390,7 +1390,7 @@ setup_tls(void)
 		fatalx("tls_config_set_protocols: %s",
 		    tls_config_error(tlsconf));
 
-	h = TAILQ_FIRST(&hosts);
+	h = TAILQ_FIRST(&conf.hosts);
 
 	/* we need to set something, then we can add how many key we want */
 	if (tls_config_set_keypair_mem(tlsconf, h->cert, h->certlen,
@@ -1421,7 +1421,7 @@ load_vhosts(void)
 	struct vhost	*h;
 	struct location	*l;
 
-	TAILQ_FOREACH(h, &hosts, vhosts) {
+	TAILQ_FOREACH(h, &conf.hosts, vhosts) {
 		TAILQ_FOREACH(l, &h->locations, locations) {
 			if (*l->dir == '\0')
 				continue;