r5660 - in trunk/varnish-cache: bin/varnishd lib/libvcl

phk at varnish-cache.org phk at varnish-cache.org
Mon Dec 20 13:39:52 CET 2010


Author: phk
Date: 2010-12-20 13:39:51 +0100 (Mon, 20 Dec 2010)
New Revision: 5660

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_pool.c
   trunk/varnish-cache/bin/varnishd/cache_vrt_var.c
   trunk/varnish-cache/lib/libvcl/generate.py
Log:
Implement beresp.storage as a string variable which lives entirely
inside vcl_fetch()



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2010-12-20 12:24:33 UTC (rev 5659)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2010-12-20 12:39:51 UTC (rev 5660)
@@ -258,6 +258,8 @@
 	double			grace;
 	unsigned		do_esi;
 
+	char			*storage;
+
 	/* Timeouts */
 	double			connect_timeout;
 	double			first_byte_timeout;

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2010-12-20 12:24:33 UTC (rev 5659)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2010-12-20 12:39:51 UTC (rev 5660)
@@ -524,6 +524,8 @@
 
 	sp->wrk->body_status = RFC2616_Body(sp);
 
+	AZ(sp->wrk->storage);
+
 	VCL_fetch_method(sp);
 
 	if (sp->objcore == NULL) {
@@ -568,6 +570,8 @@
 	sp->obj = STV_NewObject(sp, l, sp->wrk->ttl, nhttp);
 	CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
 
+	sp->wrk->storage = NULL;
+
 	if (vary != NULL) {
 		sp->obj->vary =
 		    (void *)WS_Alloc(sp->obj->http->ws, varyl);
@@ -1249,6 +1253,7 @@
 		CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
 		CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
 		WS_Assert(w->ws);
+		AZ(sp->wrk->storage);
 
 		switch (sp->step) {
 #define STEP(l,u) \

Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c	2010-12-20 12:24:33 UTC (rev 5659)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c	2010-12-20 12:39:51 UTC (rev 5660)
@@ -181,6 +181,7 @@
 		w->beresp1 = NULL;
 		w->beresp = NULL;
 		w->resp = NULL;
+		w->storage = NULL;
 		w->wrq->func(w, w->wrq->priv);
 		AZ(w->bereq);
 		AZ(w->beresp1);
@@ -188,6 +189,7 @@
 		AZ(w->resp);
 		WS_Assert(w->ws);
 		AZ(w->wfd);
+		AZ(w->storage);
 		assert(w->wlp == w->wlb);
 		w->wrq = NULL;
 		if (params->diag_bitmap & 0x00040000) {

Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_var.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_var.c	2010-12-20 12:24:33 UTC (rev 5659)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_var.c	2010-12-20 12:39:51 UTC (rev 5660)
@@ -309,7 +309,29 @@
 	return (TCP_port(sp->vbc->addr));
 }
 
+const char * __match_proto__()
+VRT_r_beresp_storage(struct sess *sp)
+{
+	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	if (sp->wrk->storage != NULL)
+		return (sp->wrk->storage);
+	else
+		return (NULL);
+}
+
 void
+VRT_l_beresp_storage(struct sess *sp, const char *str, ...)
+{
+	va_list ap;
+	char *b;
+
+	va_start(ap, str);
+	b = VRT_String(sp->wrk->ws, NULL, str, ap);
+	va_end(ap);
+	sp->wrk->storage = b;
+}
+
+void
 VRT_l_obj_ttl(const struct sess *sp, double a)
 {
 

Modified: trunk/varnish-cache/lib/libvcl/generate.py
===================================================================
--- trunk/varnish-cache/lib/libvcl/generate.py	2010-12-20 12:24:33 UTC (rev 5659)
+++ trunk/varnish-cache/lib/libvcl/generate.py	2010-12-20 12:39:51 UTC (rev 5660)
@@ -316,6 +316,12 @@
 		( ),
 		'const struct sess *'
 	),
+	('beresp.storage',
+		'STRING',
+		( 'fetch',),
+		( 'fetch',),
+		'struct sess *'
+	),
 	('obj.proto',
 		'STRING',
 		( 'hit', 'error',),




More information about the varnish-commit mailing list