r3947 - in trunk/varnish-cache: bin/varnishd include lib/libvcl

sky at projects.linpro.no sky at projects.linpro.no
Wed Mar 18 11:22:51 CET 2009


Author: sky
Date: 2009-03-18 11:22:51 +0100 (Wed, 18 Mar 2009)
New Revision: 3947

Modified:
   trunk/varnish-cache/bin/varnishd/cache_vrt.c
   trunk/varnish-cache/include/vrt_obj.h
   trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
   trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
   trunk/varnish-cache/lib/libvcl/vcc_obj.c
Log:
Add server.hostname to get the hostname, it is only checked once so if the machine changes hostname it won't detect it until restart of varnish

Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c	2009-03-18 09:46:31 UTC (rev 3946)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c	2009-03-18 10:22:51 UTC (rev 3947)
@@ -54,6 +54,7 @@
 #include "cache_backend.h"
 
 void *vrt_magic_string_end = &vrt_magic_string_end;
+char vrt_hostname[255] = "";
 
 /*--------------------------------------------------------------------*/
 
@@ -621,6 +622,15 @@
 	return (sp->mysockaddr);
 }
 
+const char*
+VRT_r_server_hostname(struct sess *sp)
+{
+	if (vrt_hostname[0] == '\0')
+		gethostname(vrt_hostname, 255);
+	
+	return (const char*) &vrt_hostname;
+}
+
 int
 VRT_r_server_port(struct sess *sp)
 {

Modified: trunk/varnish-cache/include/vrt_obj.h
===================================================================
--- trunk/varnish-cache/include/vrt_obj.h	2009-03-18 09:46:31 UTC (rev 3946)
+++ trunk/varnish-cache/include/vrt_obj.h	2009-03-18 10:22:51 UTC (rev 3947)
@@ -8,6 +8,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 *);
 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: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-03-18 09:46:31 UTC (rev 3946)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-03-18 10:22:51 UTC (rev 3947)
@@ -322,12 +322,13 @@
 
 	/* ../../include/vrt_obj.h */
 
-	vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 3838 2009-02-27 15:20:57Z ");
+	vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 3880 2009-03-04 13:00:18Z ");
 	vsb_cat(sb, "phk $\n *\n * NB:  This file is machine generated, DO ");
 	vsb_cat(sb, "NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n");
 	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 *);\nint VRT_r_server_port(struct sess *);\n");
+	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, "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: trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2009-03-18 09:46:31 UTC (rev 3946)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2009-03-18 10:22:51 UTC (rev 3947)
@@ -51,6 +51,11 @@
 	{recv pipe pass hash miss hit fetch deliver                error }
 	"struct sess *"
     }
+    { server.hostname
+	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: trunk/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_obj.c	2009-03-18 09:46:31 UTC (rev 3946)
+++ trunk/varnish-cache/lib/libvcl/vcc_obj.c	2009-03-18 10:22:51 UTC (rev 3947)
@@ -25,6 +25,13 @@
 	     | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
 	     | VCL_MET_ERROR
 	},
+	{ "server.hostname", STRING, 15,
+	    "VRT_r_server_hostname(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