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

Eliminate the cached the wrk->storage pointer, it is unnecesary.

parent b965780e
......@@ -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);
......
......@@ -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) \
......
......@@ -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)
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
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