Commit b965780e authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Hang the currently-being-filled storage segment off the object also.

parent d877e0e0
......@@ -417,7 +417,7 @@ struct lru {
};
/* Object structure --------------------------------------------------*/
VTAILQ_HEAD(objecthead, storage);
VTAILQ_HEAD(storagehead, storage);
struct object {
unsigned magic;
......@@ -452,7 +452,7 @@ struct object {
struct http *http;
struct objecthead store;
struct storagehead store;
struct storage *esidata;
......@@ -630,7 +630,7 @@ void EXP_Touch(struct object *o, double tnow);
int EXP_NukeOne(const struct sess *sp, const struct lru *lru);
/* cache_fetch.c */
int FetchStorage(const struct sess *sp);
int FetchStorage(const struct sess *sp, ssize_t sz);
int FetchHdr(struct sess *sp);
int FetchBody(struct sess *sp);
int FetchReqBody(struct sess *sp);
......
......@@ -528,7 +528,7 @@ ESI_DeliverChild(const struct sess *sp)
}
if (lpad > 0)
ved_sendchunk(sp, NULL, 0, pad, lpad);
st = VTAILQ_LAST(&sp->obj->store, objecthead);
st = VTAILQ_LAST(&sp->obj->store, storagehead);
assert(st->len > 8);
p = st->ptr + st->len - 8;
......
......@@ -77,7 +77,7 @@ vfp_esi_bytes_uu(struct sess *sp, struct http_conn *htc, ssize_t bytes)
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
while (bytes > 0) {
if (FetchStorage(sp))
if (FetchStorage(sp, 0))
return (-1);
st = sp->wrk->storage;
w = vef_read(htc,
......
......@@ -71,7 +71,7 @@ vfp_nop_begin(struct sess *sp, size_t estimate)
"Fetch %d byte segments:", fetchfrag);
}
if (estimate > 0)
sp->wrk->storage = STV_alloc(sp, estimate);
(void)FetchStorage(sp, estimate);
}
/*--------------------------------------------------------------------
......@@ -91,7 +91,7 @@ vfp_nop_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
struct storage *st;
while (bytes > 0) {
if (FetchStorage(sp))
if (FetchStorage(sp, 0))
return (-1);
st = sp->wrk->storage;
l = st->space - st->len;
......@@ -126,13 +126,15 @@ vfp_nop_end(struct sess *sp)
if (st == NULL)
return (0);
assert(st == VTAILQ_LAST(&sp->obj->store, storagehead));
if (st->len == 0) {
VTAILQ_REMOVE(&sp->obj->store, st, list);
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);
}
......@@ -147,25 +149,30 @@ static struct vfp vfp_nop = {
*/
int
FetchStorage(const struct sess *sp)
FetchStorage(const struct sess *sp, ssize_t sz)
{
ssize_t l;
if (sp->wrk->storage != NULL &&
sp->wrk->storage->len == sp->wrk->storage->space) {
VTAILQ_INSERT_TAIL(&sp->obj->store, sp->wrk->storage, list);
sp->wrk->storage->len == sp->wrk->storage->space)
sp->wrk->storage = NULL;
if (sp->wrk->storage != NULL) {
assert(sp->wrk->storage == VTAILQ_LAST(&sp->obj->store, storagehead));
return (0);
}
if (sp->wrk->storage == NULL) {
l = fetchfrag;
if (l == 0)
l = params->fetch_chunksize * 1024LL;
sp->wrk->storage = STV_alloc(sp, l);
}
l = fetchfrag;
if (l == 0)
l = sz;
if (l == 0)
l = params->fetch_chunksize * 1024LL;
sp->wrk->storage = STV_alloc(sp, l);
if (sp->wrk->storage == NULL) {
errno = ENOMEM;
return (-1);
}
AZ(sp->wrk->storage->len);
VTAILQ_INSERT_TAIL(&sp->obj->store, sp->wrk->storage, list);
return (0);
}
......
......@@ -245,7 +245,7 @@ VGZ_ObufStorage(const struct sess *sp, struct vgz *vg)
{
struct storage *st;
if (FetchStorage(sp))
if (FetchStorage(sp, 0))
return (-1);
st = sp->wrk->storage;
......@@ -527,7 +527,7 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AZ(vg->vz.avail_in);
while (bytes > 0) {
if (FetchStorage(sp))
if (FetchStorage(sp, 0))
return (-1);
st = sp->wrk->storage;
l = st->space - st->len;
......
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