[master] b965780 Hang the currently-being-filled storage segment off the object also.
Poul-Henning Kamp
phk at varnish-cache.org
Wed Jan 26 22:31:48 CET 2011
commit b965780e267b24e841809162eb180d706f4613f2
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Jan 26 21:31:24 2011 +0000
Hang the currently-being-filled storage segment off the object also.
diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index ead98c1..d2de03e 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -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);
diff --git a/bin/varnishd/cache_esi_deliver.c b/bin/varnishd/cache_esi_deliver.c
index 5a5b1a6..9c5b0cf 100644
--- a/bin/varnishd/cache_esi_deliver.c
+++ b/bin/varnishd/cache_esi_deliver.c
@@ -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;
diff --git a/bin/varnishd/cache_esi_fetch.c b/bin/varnishd/cache_esi_fetch.c
index 533fc72..24aefeb 100644
--- a/bin/varnishd/cache_esi_fetch.c
+++ b/bin/varnishd/cache_esi_fetch.c
@@ -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,
diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c
index 6b123f2..e84219f 100644
--- a/bin/varnishd/cache_fetch.c
+++ b/bin/varnishd/cache_fetch.c
@@ -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);
}
diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c
index f49e7bd..8a3908f 100644
--- a/bin/varnishd/cache_gzip.c
+++ b/bin/varnishd/cache_gzip.c
@@ -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;
More information about the varnish-commit
mailing list