r3990 - in branches/2.0/varnish-cache: bin/varnishd include lib/libvcl

tfheen at projects.linpro.no tfheen at projects.linpro.no
Mon Mar 23 13:37:43 CET 2009


Author: tfheen
Date: 2009-03-23 13:37:42 +0100 (Mon, 23 Mar 2009)
New Revision: 3990

Modified:
   branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c
   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 r3947: Add server.hostname

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: branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c	2009-03-23 12:18:21 UTC (rev 3989)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c	2009-03-23 12:37:42 UTC (rev 3990)
@@ -54,6 +54,7 @@
 #include "cache_backend.h"
 
 void *vrt_magic_string_end = &vrt_magic_string_end;
+char vrt_hostname[255] = "";
 
 /*--------------------------------------------------------------------*/
 
@@ -565,6 +566,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: branches/2.0/varnish-cache/include/vrt_obj.h
===================================================================
--- branches/2.0/varnish-cache/include/vrt_obj.h	2009-03-23 12:18:21 UTC (rev 3989)
+++ branches/2.0/varnish-cache/include/vrt_obj.h	2009-03-23 12:37:42 UTC (rev 3990)
@@ -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: 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:18:21 UTC (rev 3989)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c	2009-03-23 12:37:42 UTC (rev 3990)
@@ -329,7 +329,8 @@
 	vsb_cat(sb, "DO 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: 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:18:21 UTC (rev 3989)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2009-03-23 12:37:42 UTC (rev 3990)
@@ -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: branches/2.0/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- branches/2.0/varnish-cache/lib/libvcl/vcc_obj.c	2009-03-23 12:18:21 UTC (rev 3989)
+++ branches/2.0/varnish-cache/lib/libvcl/vcc_obj.c	2009-03-23 12:37:42 UTC (rev 3990)
@@ -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