[master] 2c88943 Move fetch_object to busyobj
Poul-Henning Kamp
phk at varnish-cache.org
Tue Nov 29 19:30:17 CET 2011
commit 2c88943245cc48241823b3848b40cfe56f8b7dcf
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Nov 29 18:30:02 2011 +0000
Move fetch_object to busyobj
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 125dd53..cb2a68e 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -329,7 +329,6 @@ struct worker {
/* Fetch stuff */
struct vbc *vbc;
- struct object *fetch_obj;
enum body_status body_status;
struct vef_priv *vef_priv;
unsigned do_stream;
@@ -501,6 +500,7 @@ struct busyobj {
unsigned fetch_failed;
struct vgz *vgz_rx;
+ struct object *fetch_obj;
struct exp exp;
struct http_conn htc;
};
diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index 71dd815..5795849 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -81,7 +81,7 @@ vfp_esi_bytes_uu(struct worker *w, struct http_conn *htc, ssize_t bytes)
return (wl);
VEP_Parse(w, (const char *)st->ptr + st->len, wl);
st->len += wl;
- w->fetch_obj->len += wl;
+ w->busyobj->fetch_obj->len += wl;
bytes -= wl;
}
return (1);
@@ -117,7 +117,7 @@ vfp_esi_bytes_gu(struct worker *w, struct http_conn *htc, ssize_t bytes)
i = VGZ_Gunzip(vg, &dp, &dl);
xxxassert(i == VGZ_OK || i == VGZ_END);
VEP_Parse(w, dp, dl);
- w->fetch_obj->len += dl;
+ w->busyobj->fetch_obj->len += dl;
}
return (1);
}
@@ -187,7 +187,7 @@ vfp_vep_callback(struct worker *w, ssize_t l, enum vgz_flag flg)
}
i = VGZ_Gzip(vef->vgz, &dp, &dl, flg);
vef->tot += dl;
- w->fetch_obj->len += dl;
+ w->busyobj->fetch_obj->len += dl;
} while (!VGZ_IbufEmpty(vef->vgz) ||
(flg != VGZ_NORMAL && VGZ_ObufFull(vef->vgz)));
if (px != 0) {
@@ -374,11 +374,11 @@ vfp_esi_end(struct worker *w)
l = VSB_len(vsb);
assert(l > 0);
/* XXX: This is a huge waste of storage... */
- w->fetch_obj->esidata = STV_alloc(w, l);
- if (w->fetch_obj->esidata != NULL) {
- memcpy(w->fetch_obj->esidata->ptr,
+ w->busyobj->fetch_obj->esidata = STV_alloc(w, l);
+ if (w->busyobj->fetch_obj->esidata != NULL) {
+ memcpy(w->busyobj->fetch_obj->esidata->ptr,
VSB_data(vsb), l);
- w->fetch_obj->esidata->len = l;
+ w->busyobj->fetch_obj->esidata->len = l;
} else {
retval = FetchError(w,
"Could not allocate storage for esidata");
@@ -391,7 +391,7 @@ vfp_esi_end(struct worker *w)
vef = w->vef_priv;
CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
w->vef_priv = NULL;
- VGZ_UpdateObj(vef->vgz, w->fetch_obj);
+ VGZ_UpdateObj(vef->vgz, w->busyobj->fetch_obj);
if (VGZ_Destroy(&vef->vgz, -1) != VGZ_END)
retval = FetchError(w,
"ESI+Gzip Failed at the very end");
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 0b86821..7180a5b 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -124,7 +124,7 @@ vfp_nop_bytes(struct worker *w, struct http_conn *htc, ssize_t bytes)
if (wl <= 0)
return (wl);
st->len += wl;
- w->fetch_obj->len += wl;
+ w->busyobj->fetch_obj->len += wl;
bytes -= wl;
if (w->do_stream)
RES_StreamPoll(w);
@@ -146,12 +146,12 @@ vfp_nop_end(struct worker *w)
{
struct storage *st;
- st = VTAILQ_LAST(&w->fetch_obj->store, storagehead);
+ st = VTAILQ_LAST(&w->busyobj->fetch_obj->store, storagehead);
if (st == NULL)
return (0);
if (st->len == 0) {
- VTAILQ_REMOVE(&w->fetch_obj->store, st, list);
+ VTAILQ_REMOVE(&w->busyobj->fetch_obj->store, st, list);
STV_free(st);
return (0);
}
@@ -178,7 +178,7 @@ FetchStorage(struct worker *w, ssize_t sz)
struct storage *st;
struct object *obj;
- obj = w->fetch_obj;
+ obj = w->busyobj->fetch_obj;
CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
st = VTAILQ_LAST(&obj->store, storagehead);
if (st != NULL && st->len < st->space)
@@ -495,7 +495,7 @@ FetchBody(struct worker *w, struct object *obj)
CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(w->busyobj, BUSYOBJ_MAGIC);
- AZ(w->fetch_obj);
+ AZ(w->busyobj->fetch_obj);
CHECK_OBJ_NOTNULL(w->vbc, VBC_MAGIC);
CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(obj->http, HTTP_MAGIC);
@@ -510,7 +510,7 @@ FetchBody(struct worker *w, struct object *obj)
AZ(w->busyobj->vgz_rx);
AZ(VTAILQ_FIRST(&obj->store));
- w->fetch_obj = obj;
+ w->busyobj->fetch_obj = obj;
w->busyobj->fetch_failed = 0;
/* XXX: pick up estimate from objdr ? */
@@ -564,7 +564,7 @@ FetchBody(struct worker *w, struct object *obj)
*/
AZ(vfp_nop_end(w));
- w->fetch_obj = NULL;
+ w->busyobj->fetch_obj = NULL;
WSLB(w, SLT_Fetch_Body, "%u(%s) cls %d mklen %u",
w->body_status, body_status(w->body_status),
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index f325292..4076081 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -492,7 +492,7 @@ vfp_gunzip_bytes(struct worker *w, struct http_conn *htc, ssize_t bytes)
i = VGZ_Gunzip(vg, &dp, &dl);
if (i != VGZ_OK && i != VGZ_END)
return(FetchError(w, "Gunzip data error"));
- w->fetch_obj->len += dl;
+ w->busyobj->fetch_obj->len += dl;
if (w->do_stream)
RES_StreamPoll(w);
}
@@ -568,7 +568,7 @@ vfp_gzip_bytes(struct worker *w, struct http_conn *htc, ssize_t bytes)
return(-1);
i = VGZ_Gzip(vg, &dp, &dl, VGZ_NORMAL);
assert(i == Z_OK);
- w->fetch_obj->len += dl;
+ w->busyobj->fetch_obj->len += dl;
if (w->do_stream)
RES_StreamPoll(w);
}
@@ -595,11 +595,11 @@ vfp_gzip_end(struct worker *w)
if (VGZ_ObufStorage(w, vg))
return(-1);
i = VGZ_Gzip(vg, &dp, &dl, VGZ_FINISH);
- w->fetch_obj->len += dl;
+ w->busyobj->fetch_obj->len += dl;
} while (i != Z_STREAM_END);
if (w->do_stream)
RES_StreamPoll(w);
- VGZ_UpdateObj(vg, w->fetch_obj);
+ VGZ_UpdateObj(vg, w->busyobj->fetch_obj);
if (VGZ_Destroy(&vg, -1) != VGZ_END)
return(FetchError(w, "Gzip error at the very end"));
return (0);
@@ -654,7 +654,7 @@ vfp_testgzip_bytes(struct worker *w, struct http_conn *htc, ssize_t bytes)
bytes -= wl;
VGZ_Ibuf(vg, st->ptr + st->len, wl);
st->len += wl;
- w->fetch_obj->len += wl;
+ w->busyobj->fetch_obj->len += wl;
if (w->do_stream)
RES_StreamPoll(w);
@@ -684,7 +684,7 @@ vfp_testgzip_end(struct worker *w)
(void)VGZ_Destroy(&vg, -1);
return(0);
}
- VGZ_UpdateObj(vg, w->fetch_obj);
+ VGZ_UpdateObj(vg, w->busyobj->fetch_obj);
if (VGZ_Destroy(&vg, -1) != VGZ_END)
return(FetchError(w, "TestGunzip error at the very end"));
return (0);
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index bdc0fca..39c0ee6 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -365,14 +365,14 @@ RES_StreamPoll(struct worker *w)
void *ptr;
CHECK_OBJ_NOTNULL(w, WORKER_MAGIC);
- CHECK_OBJ_NOTNULL(w->fetch_obj, OBJECT_MAGIC);
+ CHECK_OBJ_NOTNULL(w->busyobj->fetch_obj, OBJECT_MAGIC);
sctx = w->sctx;
CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC);
- if (w->fetch_obj->len == sctx->stream_next)
+ if (w->busyobj->fetch_obj->len == sctx->stream_next)
return;
- assert(w->fetch_obj->len > sctx->stream_next);
+ assert(w->busyobj->fetch_obj->len > sctx->stream_next);
l = sctx->stream_front;
- VTAILQ_FOREACH(st, &w->fetch_obj->store, list) {
+ VTAILQ_FOREACH(st, &w->busyobj->fetch_obj->store, list) {
if (st->len + l <= sctx->stream_next) {
l += st->len;
continue;
@@ -391,18 +391,18 @@ RES_StreamPoll(struct worker *w)
if (!(w->res_mode & RES_GUNZIP))
(void)WRW_Flush(w);
- if (w->fetch_obj->objcore == NULL ||
- (w->fetch_obj->objcore->flags & OC_F_PASS)) {
+ if (w->busyobj->fetch_obj->objcore == NULL ||
+ (w->busyobj->fetch_obj->objcore->flags & OC_F_PASS)) {
/*
* This is a pass object, release storage as soon as we
* have delivered it.
*/
while (1) {
- st = VTAILQ_FIRST(&w->fetch_obj->store);
+ st = VTAILQ_FIRST(&w->busyobj->fetch_obj->store);
if (st == NULL ||
sctx->stream_front + st->len > sctx->stream_next)
break;
- VTAILQ_REMOVE(&w->fetch_obj->store, st, list);
+ VTAILQ_REMOVE(&w->busyobj->fetch_obj->store, st, list);
sctx->stream_front += st->len;
STV_free(st);
}
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index d0b4226..2748999 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -367,7 +367,7 @@ struct storage *
STV_alloc(struct worker *w, size_t size)
{
- return (stv_alloc(w, w->fetch_obj, size));
+ return (stv_alloc(w, w->busyobj->fetch_obj, size));
}
void
More information about the varnish-commit
mailing list