Commit 76c392cc authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

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
parent ba293755
......@@ -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);
}
......
......@@ -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",
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment