r433 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Tue Jul 11 18:25:50 CEST 2006


Author: phk
Date: 2006-07-11 18:25:49 +0200 (Tue, 11 Jul 2006)
New Revision: 433

Modified:
   trunk/varnish-cache/bin/varnishd/varnishd.c
Log:
Allow backend to be specified as "host:port" to -b



Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c	2006-07-11 16:17:13 UTC (rev 432)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c	2006-07-11 16:25:49 UTC (rev 433)
@@ -66,6 +66,7 @@
 vcl_default(const char *bflag)
 {
 	char *buf, *vf;
+	const char *p, *q;
 	struct sbuf *sb;
 
 	/*
@@ -76,10 +77,19 @@
 	 * XXX: a bug for a backend to not reply at that time, so then
 	 * XXX: again: we should check it here in the "trivial" case.
 	 */
+	p = strchr(bflag, ':');
+	if (p != NULL) {
+		q = p + 1;
+	} else {
+		p = strchr(bflag, '\0');
+		q = "http";
+	}
+	
 	buf = NULL;
 	asprintf(&buf,
 	    "backend default {\n"
-	    "    set backend.host = \"%s\";\n"
+	    "    set backend.host = \"%*.*s\";\n"
+	    "    set backend.port = \"%s\";\n"
 	    "}\n"
 	    "sub vcl_recv {\n"
 	    "    if (req.request != \"GET\" && req.request != \"HEAD\") {\n"
@@ -117,7 +127,7 @@
 	    "sub vcl_timeout {\n"
 	    "    discard;\n"
 	    "}\n"
-	    "", bflag);
+	    "", p - bflag, p - bflag, bflag, q);
 	assert(buf != NULL);
 	sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
 	assert(sb != NULL);




More information about the varnish-commit mailing list