[master] 9584dc0 Move cache_param entirely into the cache * namespace and communicate it via heritage.

Poul-Henning Kamp phk at varnish-cache.org
Mon Nov 21 00:39:24 CET 2011


commit 9584dc0365f172d2d59569d15836f1c58c803771
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sun Nov 20 19:59:58 2011 +0000

    Move cache_param entirely into the cache * namespace and communicate
    it via heritage.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index e08cc32..4b66309 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -784,6 +784,7 @@ int HTC_Complete(struct http_conn *htc);
 #undef HTTPH
 
 /* cache_main.c */
+extern volatile struct params * cache_param;
 void THR_SetName(const char *name);
 const char* THR_GetName(void);
 void THR_SetSession(const struct sess *sp);
diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c
index eb3fa1d..568e5e5 100644
--- a/bin/varnishd/cache/cache_main.c
+++ b/bin/varnishd/cache/cache_main.c
@@ -96,6 +96,8 @@ child_main(void)
 	setbuf(stderr, NULL);
 	printf("Child starts\n");
 
+	cache_param = heritage.param;
+
 	AZ(pthread_key_create(&sp_key, NULL));
 	AZ(pthread_key_create(&name_key, NULL));
 
diff --git a/bin/varnishd/common/heritage.h b/bin/varnishd/common/heritage.h
index db8b1f0..4ad9deb 100644
--- a/bin/varnishd/common/heritage.h
+++ b/bin/varnishd/common/heritage.h
@@ -60,6 +60,8 @@ struct heritage {
 
 	struct vsm_sc			*vsm;
 
+	struct params			*param;
+
 	char				*name;
 	char                            identity[1024];
 };
diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h
index cab2f49..b9b758f 100644
--- a/bin/varnishd/common/params.h
+++ b/bin/varnishd/common/params.h
@@ -193,9 +193,3 @@ struct params {
 	ssize_t			vsm_space;
 	ssize_t			vsl_space;
 };
-
-/*
- * We declare this a volatile pointer, so that reads of parameters
- * become atomic, leaving the CLI thread lattitude to change the values
- */
-extern volatile struct params * cache_param;
diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c
index b619b66..4afcf81 100644
--- a/bin/varnishd/mgt/mgt_child.c
+++ b/bin/varnishd/mgt/mgt_child.c
@@ -315,7 +315,7 @@ start_child(struct cli *cli)
 	heritage.std_fd = cp[1];
 	child_output = cp[0];
 
-	AN(cache_param);
+	AN(heritage.param);
 	if ((pid = fork()) < 0) {
 		perror("Could not fork child");
 		exit(1);
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index f6de562..e4be5d8 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -1205,8 +1205,8 @@ MCF_ParamSet(struct cli *cli, const char *param, const char *val)
 	}
 	pp->func(cli, pp, val);
 
-	if (cli->result == CLIS_OK && cache_param != NULL)
-		*cache_param = mgt_param;
+	if (cli->result == CLIS_OK && heritage.param != NULL)
+		*heritage.param = mgt_param;
 
 	if (cli->result != CLIS_OK) {
 		VCLI_Out(cli, "(attempting to set param %s to %s)\n",
diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c
index 5915b19..66eb035 100644
--- a/bin/varnishd/mgt/mgt_shmem.c
+++ b/bin/varnishd/mgt/mgt_shmem.c
@@ -210,9 +210,10 @@ mgt_SHM_Init(void)
 
 	AZ(atexit(mgt_shm_atexit));
 
-	cache_param = VSM_Alloc(sizeof *cache_param, VSM_CLASS_PARAM, "", "");
-	AN(cache_param);
-	*cache_param = mgt_param;
+	heritage.param =
+	    VSM_Alloc(sizeof *heritage.param, VSM_CLASS_PARAM, "", "");
+	AN(heritage.param);
+	*heritage.param = mgt_param;
 
 	PAN_panicstr_len = 64 * 1024;
 	PAN_panicstr = VSM_Alloc(PAN_panicstr_len, PAN_CLASS, "", "");



More information about the varnish-commit mailing list