r3992 - in branches/2.0/varnish-cache: bin/varnishd bin/varnishtest/tests include lib/libvcl

tfheen at projects.linpro.no tfheen at projects.linpro.no
Mon Mar 23 13:50:04 CET 2009


Author: tfheen
Date: 2009-03-23 13:50:04 +0100 (Mon, 23 Mar 2009)
New Revision: 3992

Modified:
   branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c
   branches/2.0/varnish-cache/bin/varnishd/heritage.h
   branches/2.0/varnish-cache/bin/varnishd/varnishd.c
   branches/2.0/varnish-cache/bin/varnishtest/tests/v00001.vtc
   branches/2.0/varnish-cache/include/vrt_obj.h
   branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c
   branches/2.0/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
   branches/2.0/varnish-cache/lib/libvcl/vcc_obj.c
Log:
Merge r3949: add new option to set the identity of a varnish instance and allow it to be accessed using server.identity



Modified: branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c	2009-03-23 12:42:15 UTC (rev 3991)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c	2009-03-23 12:50:04 UTC (rev 3992)
@@ -567,6 +567,16 @@
 }
 
 const char*
+VRT_r_server_identity(struct sess *sp)
+{
+	if (heritage.identity[0] != '\0')
+		return heritage.identity;
+	else 
+		return heritage.name;
+}
+
+
+const char*
 VRT_r_server_hostname(struct sess *sp)
 {
 	if (vrt_hostname[0] == '\0')

Modified: branches/2.0/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/heritage.h	2009-03-23 12:42:15 UTC (rev 3991)
+++ branches/2.0/varnish-cache/bin/varnishd/heritage.h	2009-03-23 12:50:04 UTC (rev 3992)
@@ -65,6 +65,7 @@
 	struct hash_slinger		*hash;
 
 	char				name[1024];
+	char                            identity[1024];
 };
 
 struct params {

Modified: branches/2.0/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/varnishd.c	2009-03-23 12:42:15 UTC (rev 3991)
+++ branches/2.0/varnish-cache/bin/varnishd/varnishd.c	2009-03-23 12:50:04 UTC (rev 3992)
@@ -216,6 +216,7 @@
 	fprintf(stderr, FMT, "", "  -h simple_list");
 	fprintf(stderr, FMT, "", "  -h classic  [default]");
 	fprintf(stderr, FMT, "", "  -h classic,<buckets>");
+	fprintf(stderr, FMT, "-i identity", "Identity of varnish instance");
 	fprintf(stderr, FMT, "-l bytesize", "Size of shared memory log");
 	fprintf(stderr, FMT, "-n dir", "varnishd working directory");
 	fprintf(stderr, FMT, "-P file", "PID file");
@@ -424,6 +425,7 @@
 	unsigned F_flag = 0;
 	const char *b_arg = NULL;
 	const char *f_arg = NULL;
+	const char *i_arg = NULL;
 	const char *l_arg = "80m";
 	uintmax_t l_size;
 	const char *q;
@@ -471,7 +473,7 @@
 	cli_check(cli);
 
 	while ((o = getopt(argc, argv,
-	    "a:b:Cdf:Fg:h:l:n:P:p:s:T:t:u:Vw:")) != -1)
+	    "a:b:Cdf:Fg:h:i:l:n:P:p:s:T:t:u:Vw:")) != -1)
 		switch (o) {
 		case 'a':
 			MCF_ParamSet(cli, "listen_address", optarg);
@@ -498,6 +500,9 @@
 		case 'h':
 			h_arg = optarg;
 			break;
+		case 'i':
+			i_arg = optarg;
+			break;
 		case 'l':
 			l_arg = optarg;
 			break;
@@ -589,6 +594,17 @@
 		exit(1);
 	}
 
+
+	if (i_arg != NULL) {
+		size_t len;
+		if (snprintf(heritage.identity, sizeof heritage.identity, "%s", i_arg) > sizeof heritage.identity) {
+			fprintf(stderr, "Invalid identity name: %s\n",
+			    strerror(ENAMETOOLONG));
+			exit(1);
+		}
+	}
+	
+
 	if (n_arg != NULL)
 		openlog(n_arg, LOG_PID, LOG_LOCAL0);
 	else

Modified: branches/2.0/varnish-cache/bin/varnishtest/tests/v00001.vtc
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/v00001.vtc	2009-03-23 12:42:15 UTC (rev 3991)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/v00001.vtc	2009-03-23 12:50:04 UTC (rev 3992)
@@ -39,6 +39,9 @@
 		set resp.proto = "HTTP/1.2";
 		set resp.response = "Naah, lets fail it";
 		set resp.status = 904;
+		# XXX should be moved to it's own test
+		set resp.http.x-served-by-hostname = server.hostname;
+		set resp.http.x-served-by-identity = server.identity;
 		set resp.http.foobar =
 		    resp.proto
 		    resp.status;

Modified: branches/2.0/varnish-cache/include/vrt_obj.h
===================================================================
--- branches/2.0/varnish-cache/include/vrt_obj.h	2009-03-23 12:42:15 UTC (rev 3991)
+++ branches/2.0/varnish-cache/include/vrt_obj.h	2009-03-23 12:50:04 UTC (rev 3992)
@@ -9,6 +9,7 @@
 struct sockaddr * VRT_r_client_ip(const struct sess *);
 struct sockaddr * VRT_r_server_ip(struct sess *);
 const char * VRT_r_server_hostname(struct sess *);
+const char * VRT_r_server_identity(struct sess *);
 int VRT_r_server_port(struct sess *);
 const char * VRT_r_req_request(const struct sess *);
 void VRT_l_req_request(const struct sess *, const char *, ...);

Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-03-23 12:42:15 UTC (rev 3991)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-03-23 12:50:04 UTC (rev 3992)
@@ -159,8 +159,8 @@
 
 	/* ../../include/vcl.h */
 
-	vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 3718 2009-02-10 14");
-	vsb_cat(sb, ":25:49Z tfheen $\n *\n * NB:  This file is machine gen");
+	vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 3991 2009-03-23 12");
+	vsb_cat(sb, ":42:15Z tfheen $\n *\n * NB:  This file is machine gen");
 	vsb_cat(sb, "erated, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixe");
 	vsb_cat(sb, "d_token.tcl instead\n */\n\nstruct sess;\n");
 	vsb_cat(sb, "struct cli;\n\ntypedef void vcl_init_f(struct cli *);\n");
@@ -330,7 +330,8 @@
 	vsb_cat(sb, " */\n\nstruct sockaddr * VRT_r_client_ip(const struct ");
 	vsb_cat(sb, "sess *);\nstruct sockaddr * VRT_r_server_ip(struct ses");
 	vsb_cat(sb, "s *);\nconst char * VRT_r_server_hostname(struct sess ");
-	vsb_cat(sb, "*);\nint VRT_r_server_port(struct sess *);\n");
+	vsb_cat(sb, "*);\nconst char * VRT_r_server_identity(struct sess *)");
+	vsb_cat(sb, ";\nint VRT_r_server_port(struct sess *);\n");
 	vsb_cat(sb, "const char * VRT_r_req_request(const struct sess *);\n");
 	vsb_cat(sb, "void VRT_l_req_request(const struct sess *, const char");
 	vsb_cat(sb, " *, ...);\nconst char * VRT_r_req_url(const struct ses");

Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2009-03-23 12:42:15 UTC (rev 3991)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2009-03-23 12:50:04 UTC (rev 3992)
@@ -56,6 +56,11 @@
 	{recv pipe pass hash miss hit fetch deliver                error }
 	"struct sess *"
     }
+    { server.identity
+	RO STRING
+	{recv pipe pass hash miss hit fetch deliver                error }
+	"struct sess *"
+    }
     { server.port
 	RO INT
 	{recv pipe pass hash miss hit fetch deliver                error }

Modified: branches/2.0/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_obj.c	2009-03-23 12:42:15 UTC (rev 3991)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_obj.c	2009-03-23 12:50:04 UTC (rev 3992)
@@ -32,6 +32,13 @@
 	     | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
 	     | VCL_MET_ERROR
 	},
+	{ "server.identity", STRING, 15,
+	    "VRT_r_server_identity(sp)",	    NULL,
+	    V_RO,	    0,
+	    VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+	     | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+	     | VCL_MET_ERROR
+	},
 	{ "server.port", INT, 11,
 	    "VRT_r_server_port(sp)",	    NULL,
 	    V_RO,	    0,



More information about the varnish-commit mailing list