r5718 - trunk/varnish-cache/bin/varnishd
phk at varnish-cache.org
phk at varnish-cache.org
Wed Jan 12 14:37:12 CET 2011
Author: phk
Date: 2011-01-12 14:37:11 +0100 (Wed, 12 Jan 2011)
New Revision: 5718
Added:
trunk/varnish-cache/bin/varnishd/cache_esi_deliver.c
Modified:
trunk/varnish-cache/bin/varnishd/Makefile.am
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_esi_parse.c
trunk/varnish-cache/bin/varnishd/cache_response.c
Log:
Add new esi delivery function which very noisily can pass e00001.vtc
Modified: trunk/varnish-cache/bin/varnishd/Makefile.am
===================================================================
--- trunk/varnish-cache/bin/varnishd/Makefile.am 2011-01-12 13:10:08 UTC (rev 5717)
+++ trunk/varnish-cache/bin/varnishd/Makefile.am 2011-01-12 13:37:11 UTC (rev 5718)
@@ -26,6 +26,7 @@
cache_dir_dns.c \
cache_dir_round_robin.c \
cache_esi_parse.c \
+ cache_esi_deliver.c \
cache_esi.c \
cache_expire.c \
cache_fetch.c \
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2011-01-12 13:10:08 UTC (rev 5717)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2011-01-12 13:37:11 UTC (rev 5718)
@@ -811,6 +811,8 @@
void ESI_Deliver(struct sess *);
void ESI_Destroy(struct object *);
void ESI_Parse(struct sess *);
+#else
+void ESI_Deliver(struct sess *);
#endif /* OLD_ESI */
/* cache_vrt_vmod.c */
Added: trunk/varnish-cache/bin/varnishd/cache_esi_deliver.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_esi_deliver.c (rev 0)
+++ trunk/varnish-cache/bin/varnishd/cache_esi_deliver.c 2011-01-12 13:37:11 UTC (rev 5718)
@@ -0,0 +1,96 @@
+/*-
+ * Copyright (c) 2011 Varnish Software AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include "config.h"
+
+#include "svnid.h"
+SVNID("$Id")
+
+#include "cache.h"
+#include "cache_esi.h"
+#include "vend.h"
+#include "vct.h"
+#include "stevedore.h"
+
+#include <stdio.h>
+
+#ifndef OLD_ESI
+
+void
+ESI_Deliver(struct sess *sp)
+{
+ struct storage *st;
+ uint8_t *p, *e, *q;
+ unsigned off;
+ size_t l;
+
+printf("DELIV\n");
+fflush(stdout);
+sleep(1);
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ st = sp->obj->esidata;
+ AN(st);
+ p = st->ptr;
+ e = st->ptr + st->len;
+
+ st = VTAILQ_FIRST(&sp->obj->store);
+ off = 0;
+
+ while (p < e) {
+ switch (*p) {
+ case VEC_V1:
+ l = p[1];
+ p += 2;
+ q = (void*)strchr((const char*)p, '\0');
+ assert (q > p);
+ printf("VER(%d) %d\n", (int)l, (int)(q-p));
+ if (sp->wrk->res_mode & RES_CHUNKED)
+ WRW_Write(sp->wrk, p, q - p);
+ WRW_Write(sp->wrk, st->ptr + off, l);
+ if (sp->wrk->res_mode & RES_CHUNKED)
+ WRW_Write(sp->wrk, "\r\n", -1);
+ printf("[%.*s]", (int)l, st->ptr + off);
+ off += l;
+ p = q + 1;
+ break;
+ case VEC_S1:
+ l = p[1];
+ p += 2;
+ printf("SKIP(%d)\n", (int)l);
+ off += l;
+ break;
+ default:
+ printf("XXXX %02x [%c]\n", *p, *p);
+ return;
+ }
+ }
+ WRW_Flush(sp->wrk);
+}
+
+#endif /* OLD_ESI */
Modified: trunk/varnish-cache/bin/varnishd/cache_esi_parse.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_esi_parse.c 2011-01-12 13:10:08 UTC (rev 5717)
+++ trunk/varnish-cache/bin/varnishd/cache_esi_parse.c 2011-01-12 13:37:11 UTC (rev 5718)
@@ -170,6 +170,7 @@
vbe32enc(buf + 1, (uint32_t)l);
vsb_bcat(vep->vsb, buf, 5);
}
+ vsb_printf(vep->vsb, "%lx\r\n%c", l, 0);
vep->ver_p = p;
}
@@ -411,6 +412,7 @@
sp->obj->esidata = STV_alloc(sp, vsb_len(vep->vsb));
AN(sp->obj->esidata);
memcpy(sp->obj->esidata->ptr, vsb_data(vep->vsb), vsb_len(vep->vsb));
+ sp->obj->esidata->len = vsb_len(vep->vsb);
st = sp->wrk->storage;
sp->wrk->storage = NULL;
Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c 2011-01-12 13:10:08 UTC (rev 5717)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c 2011-01-12 13:37:11 UTC (rev 5718)
@@ -386,10 +386,8 @@
/* This was a HEAD request */
} else if (sp->obj->len == 0) {
/* Nothing to do here */
-#ifdef OLD_ESI
} else if (sp->wrk->res_mode & RES_ESI) {
ESI_Deliver(sp);
-#endif
} else if (sp->wrk->res_mode & RES_GUNZIP) {
res_WriteGunzipObj(sp, lenbuf);
} else {
More information about the varnish-commit
mailing list