[master] c5e69db Eliminate the cached the wrk->storage pointer, it is unnecesary.
Poul-Henning Kamp
phk at varnish-cache.org
Wed Jan 26 22:50:00 CET 2011
commit c5e69db8e2cfb03e294679eaf5bef4ba394e6587
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Jan 26 21:49:15 2011 +0000
Eliminate the cached the wrk->storage pointer, it is unnecesary.
diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index d2de03e..115ccf7 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -279,7 +279,6 @@ struct worker {
/* Fetch stuff */
enum body_status body_status;
- struct storage *storage;
struct vfp *vfp;
struct vgz *vgz_rx;
struct vef_priv *vef_priv;
@@ -630,7 +629,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, ssize_t sz);
+struct storage *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_center.c b/bin/varnishd/cache_center.c
index 1085fa0..16d1a7e 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -1367,7 +1367,6 @@ CNT_Session(struct sess *sp)
CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
WS_Assert(w->ws);
AZ(sp->wrk->storage_hint);
- AZ(sp->wrk->storage);
switch (sp->step) {
#define STEP(l,u) \
diff --git a/bin/varnishd/cache_esi_fetch.c b/bin/varnishd/cache_esi_fetch.c
index 24aefeb..ff36f28 100644
--- a/bin/varnishd/cache_esi_fetch.c
+++ b/bin/varnishd/cache_esi_fetch.c
@@ -77,9 +77,9 @@ 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, 0))
+ st = FetchStorage(sp, 0);
+ if (st == NULL)
return (-1);
- st = sp->wrk->storage;
w = vef_read(htc,
st->ptr + st->len, st->space - st->len, bytes);
if (w <= 0)
diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c
index e84219f..22cce8c 100644
--- a/bin/varnishd/cache_fetch.c
+++ b/bin/varnishd/cache_fetch.c
@@ -64,7 +64,6 @@ static void __match_proto__()
vfp_nop_begin(struct sess *sp, size_t estimate)
{
- AZ(sp->wrk->storage);
if (fetchfrag > 0) {
estimate = fetchfrag;
WSL(sp->wrk, SLT_Debug, sp->fd,
@@ -91,9 +90,9 @@ vfp_nop_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
struct storage *st;
while (bytes > 0) {
- if (FetchStorage(sp, 0))
+ st = FetchStorage(sp, 0);
+ if (st == NULL)
return (-1);
- st = sp->wrk->storage;
l = st->space - st->len;
if (l > bytes)
l = bytes;
@@ -121,13 +120,10 @@ vfp_nop_end(struct sess *sp)
{
struct storage *st;
- st = sp->wrk->storage;
- sp->wrk->storage = NULL;
+ st = VTAILQ_LAST(&sp->obj->store, storagehead);
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);
@@ -148,32 +144,29 @@ static struct vfp vfp_nop = {
* Fetch Storage
*/
-int
+struct storage *
FetchStorage(const struct sess *sp, ssize_t sz)
{
ssize_t l;
+ struct storage *st;
- if (sp->wrk->storage != NULL &&
- 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);
- }
+ st = VTAILQ_LAST(&sp->obj->store, storagehead);
+ if (st != NULL && st->len < st->space)
+ return (st);
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) {
+ st = STV_alloc(sp, l);
+ if (st == NULL) {
errno = ENOMEM;
- return (-1);
+ return (NULL);
}
- AZ(sp->wrk->storage->len);
- VTAILQ_INSERT_TAIL(&sp->obj->store, sp->wrk->storage, list);
- return (0);
+ AZ(st->len);
+ VTAILQ_INSERT_TAIL(&sp->obj->store, st, list);
+ return (st);
}
/*--------------------------------------------------------------------
@@ -514,7 +507,7 @@ FetchBody(struct sess *sp)
* XXX: Missing: RFC2616 sec. 4.4 in re 1xx, 204 & 304 responses
*/
- AZ(sp->wrk->storage);
+ AZ(VTAILQ_FIRST(&sp->obj->store));
switch (sp->wrk->body_status) {
case BS_NONE:
cls = 0;
@@ -553,7 +546,6 @@ FetchBody(struct sess *sp)
* 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",
sp->wrk->body_status, cls, mklen);
diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c
index 8a3908f..930d7f1 100644
--- a/bin/varnishd/cache_gzip.c
+++ b/bin/varnishd/cache_gzip.c
@@ -245,10 +245,10 @@ VGZ_ObufStorage(const struct sess *sp, struct vgz *vg)
{
struct storage *st;
- if (FetchStorage(sp, 0))
+ st = FetchStorage(sp, 0);
+ if (st == NULL)
return (-1);
- st = sp->wrk->storage;
vg->obuf = st;
VGZ_Obuf(vg, st->ptr + st->len, st->space - st->len);
@@ -527,9 +527,9 @@ 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, 0))
+ st = FetchStorage(sp, 0);
+ if (st == NULL)
return (-1);
- st = sp->wrk->storage;
l = st->space - st->len;
if (l > bytes)
l = bytes;
diff --git a/bin/varnishd/cache_pool.c b/bin/varnishd/cache_pool.c
index 4654002..27b7253 100644
--- a/bin/varnishd/cache_pool.c
+++ b/bin/varnishd/cache_pool.c
@@ -182,13 +182,11 @@ wrk_thread_real(struct wq *qp, unsigned shm_workspace, unsigned sess_workspace,
w->beresp = NULL;
w->resp = NULL;
w->storage_hint = NULL;
- w->storage = NULL;
w->wrq->func(w, w->wrq->priv);
AZ(w->bereq);
AZ(w->beresp1);
AZ(w->beresp);
AZ(w->resp);
- AZ(w->storage);
WS_Assert(w->ws);
AZ(w->wfd);
AZ(w->storage_hint);
More information about the varnish-commit
mailing list