[master] 76c392c Always explicitly call vfp_nop_end() after the "real" VFP->end() to tuck in the last storage segment sitting on sp->work->storage, rather than have this code duplicated througout all the VFP->end()'s
Poul-Henning Kamp
phk at project.varnish-software.com
Fri Jan 21 23:38:09 CET 2011
commit 76c392cc6670774d6d9fa30b88fcaae2e13122ff
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Fri Jan 21 22:36:47 2011 +0000
Always explicitly call vfp_nop_end() after the "real" VFP->end()
to tuck in the last storage segment sitting on sp->work->storage,
rather than have this code duplicated througout all the VFP->end()'s
diff --git a/bin/varnishd/cache_esi_fetch.c b/bin/varnishd/cache_esi_fetch.c
index e2ebc1d..116b96e 100644
--- a/bin/varnishd/cache_esi_fetch.c
+++ b/bin/varnishd/cache_esi_fetch.c
@@ -292,7 +292,6 @@ printf("BYTES = %d\n", i);
static int __match_proto__()
vfp_esi_end(struct sess *sp)
{
- struct storage *st;
struct vsb *vsb;
struct vef_priv *vef;
ssize_t l;
@@ -315,9 +314,6 @@ printf("END\n");
vsb_delete(vsb);
}
- st = sp->wrk->storage;
- sp->wrk->storage = NULL;
-
if (sp->wrk->vef_priv != NULL) {
vef = sp->wrk->vef_priv;
sp->wrk->vef_priv = NULL;
@@ -326,17 +322,6 @@ printf("END\n");
printf("TOT %jd\n", vef->tot);
sp->obj->len = vef->tot;
}
-
- if (st == NULL)
- return (0);
-
- if (st->len == 0) {
- STV_free(st);
- return (0);
- }
- if (st->len < st->space)
- STV_trim(st, st->len);
- VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
return (0);
}
diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c
index d28dd5d..1e8c337 100644
--- a/bin/varnishd/cache_fetch.c
+++ b/bin/varnishd/cache_fetch.c
@@ -533,6 +533,12 @@ FetchBody(struct sess *sp)
INCOMPL();
}
XXXAZ(sp->wrk->vfp->end(sp));
+ /*
+ * It is OK for ->end to just leave the last storage segment
+ * sitting on sp->wrk->storage, we will always call vfp_nop_end()
+ * to get it trimmed and added to the object.
+ */
+ XXXAZ(vfp_nop_end(sp));
AZ(sp->wrk->storage);
WSL(sp->wrk, SLT_Fetch_Body, sp->vbc->fd, "%u %d %u",
diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c
index 8d0980c..08df961 100644
--- a/bin/varnishd/cache_gzip.c
+++ b/bin/varnishd/cache_gzip.c
@@ -390,24 +390,10 @@ static int __match_proto__()
vfp_gunzip_end(struct sess *sp)
{
struct vgz *vg;
- struct storage *st;
vg = sp->wrk->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
VGZ_Destroy(&vg);
-
- st = sp->wrk->storage;
- sp->wrk->storage = NULL;
- if (st == NULL)
- return (0);
-
- if (st->len == 0) {
- STV_free(st);
- return (0);
- }
- if (st->len < st->space)
- STV_trim(st, st->len);
- VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
return (0);
}
@@ -472,7 +458,6 @@ vfp_gzip_end(struct sess *sp)
size_t dl;
const void *dp;
int i;
- struct storage *st;
vg = sp->wrk->vgz_rx;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
@@ -484,15 +469,6 @@ vfp_gzip_end(struct sess *sp)
sp->obj->len += dl;
} while (i != Z_STREAM_END);
VGZ_Destroy(&vg);
-
- st = sp->wrk->storage;
- sp->wrk->storage = NULL;
- if (st != NULL && st->len == 0) {
- STV_free(st);
- } else if (st != NULL && st->len < st->space) {
- STV_trim(st, st->len);
- VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
- }
return (0);
}
More information about the varnish-commit
mailing list