Commit 78f18e85 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Give the worker a "fetch_obj" to avoid passing it around as a separate

parameter all the time.

Also decontaminate FetchStorage to not need session
parent 57240f5a
...@@ -339,6 +339,7 @@ struct worker { ...@@ -339,6 +339,7 @@ struct worker {
/* Fetch stuff */ /* Fetch stuff */
struct vbc *vbc; struct vbc *vbc;
struct object *fetch_obj;
enum body_status body_status; enum body_status body_status;
struct vfp *vfp; struct vfp *vfp;
struct vgz *vgz_rx; struct vgz *vgz_rx;
...@@ -700,7 +701,7 @@ int EXP_Touch(struct objcore *oc); ...@@ -700,7 +701,7 @@ int EXP_Touch(struct objcore *oc);
int EXP_NukeOne(struct worker *w, struct lru *lru); int EXP_NukeOne(struct worker *w, struct lru *lru);
/* cache_fetch.c */ /* cache_fetch.c */
struct storage *FetchStorage(const struct sess *sp, ssize_t sz); struct storage *FetchStorage(struct worker *w, ssize_t sz);
int FetchHdr(struct sess *sp); int FetchHdr(struct sess *sp);
int FetchBody(struct sess *sp, struct object *obj); int FetchBody(struct sess *sp, struct object *obj);
int FetchReqBody(struct sess *sp); int FetchReqBody(struct sess *sp);
...@@ -950,8 +951,7 @@ int RFC2616_Do_Cond(const struct sess *sp); ...@@ -950,8 +951,7 @@ int RFC2616_Do_Cond(const struct sess *sp);
/* stevedore.c */ /* stevedore.c */
struct object *STV_NewObject(struct sess *sp, const char *hint, unsigned len, struct object *STV_NewObject(struct sess *sp, const char *hint, unsigned len,
struct exp *, uint16_t nhttp); struct exp *, uint16_t nhttp);
struct storage *STV_alloc(struct worker *w, const struct object *obj, struct storage *STV_alloc(struct worker *w, size_t size);
size_t size);
void STV_trim(struct storage *st, size_t size); void STV_trim(struct storage *st, size_t size);
void STV_free(struct storage *st); void STV_free(struct storage *st);
void STV_open(void); void STV_open(void);
......
...@@ -71,7 +71,7 @@ vfp_esi_bytes_uu(struct sess *sp, struct http_conn *htc, ssize_t bytes) ...@@ -71,7 +71,7 @@ vfp_esi_bytes_uu(struct sess *sp, struct http_conn *htc, ssize_t bytes)
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
while (bytes > 0) { while (bytes > 0) {
st = FetchStorage(sp, 0); st = FetchStorage(sp->wrk, 0);
if (st == NULL) if (st == NULL)
return (-1); return (-1);
w = vef_read(htc, w = vef_read(htc,
...@@ -368,7 +368,7 @@ vfp_esi_end(struct sess *sp) ...@@ -368,7 +368,7 @@ vfp_esi_end(struct sess *sp)
l = VSB_len(vsb); l = VSB_len(vsb);
assert(l > 0); assert(l > 0);
/* XXX: This is a huge waste of storage... */ /* XXX: This is a huge waste of storage... */
sp->obj->esidata = STV_alloc(sp->wrk, sp->obj, l); sp->obj->esidata = STV_alloc(sp->wrk, l);
XXXAN(sp->obj->esidata); XXXAN(sp->obj->esidata);
memcpy(sp->obj->esidata->ptr, VSB_data(vsb), l); memcpy(sp->obj->esidata->ptr, VSB_data(vsb), l);
sp->obj->esidata->len = l; sp->obj->esidata->len = l;
......
...@@ -66,7 +66,7 @@ vfp_nop_begin(struct sess *sp, size_t estimate) ...@@ -66,7 +66,7 @@ vfp_nop_begin(struct sess *sp, size_t estimate)
WSP(sp, SLT_Debug, "Fetch %d byte segments:", fetchfrag); WSP(sp, SLT_Debug, "Fetch %d byte segments:", fetchfrag);
} }
if (estimate > 0) if (estimate > 0)
(void)FetchStorage(sp, estimate); (void)FetchStorage(sp->wrk, estimate);
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
...@@ -86,7 +86,7 @@ vfp_nop_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes) ...@@ -86,7 +86,7 @@ vfp_nop_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
struct storage *st; struct storage *st;
while (bytes > 0) { while (bytes > 0) {
st = FetchStorage(sp, 0); st = FetchStorage(sp->wrk, 0);
if (st == NULL) { if (st == NULL) {
htc->error = "Could not get storage"; htc->error = "Could not get storage";
return (-1); return (-1);
...@@ -145,12 +145,15 @@ static struct vfp vfp_nop = { ...@@ -145,12 +145,15 @@ static struct vfp vfp_nop = {
*/ */
struct storage * struct storage *
FetchStorage(const struct sess *sp, ssize_t sz) FetchStorage(struct worker *w, ssize_t sz)
{ {
ssize_t l; ssize_t l;
struct storage *st; struct storage *st;
struct object *obj;
st = VTAILQ_LAST(&sp->obj->store, storagehead); obj = w->fetch_obj;
CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
st = VTAILQ_LAST(&obj->store, storagehead);
if (st != NULL && st->len < st->space) if (st != NULL && st->len < st->space)
return (st); return (st);
...@@ -159,13 +162,13 @@ FetchStorage(const struct sess *sp, ssize_t sz) ...@@ -159,13 +162,13 @@ FetchStorage(const struct sess *sp, ssize_t sz)
l = sz; l = sz;
if (l == 0) if (l == 0)
l = params->fetch_chunksize * 1024LL; l = params->fetch_chunksize * 1024LL;
st = STV_alloc(sp->wrk, sp->obj, l); st = STV_alloc(w, l);
if (st == NULL) { if (st == NULL) {
errno = ENOMEM; errno = ENOMEM;
return (NULL); return (NULL);
} }
AZ(st->len); AZ(st->len);
VTAILQ_INSERT_TAIL(&sp->obj->store, st, list); VTAILQ_INSERT_TAIL(&obj->store, st, list);
return (st); return (st);
} }
...@@ -487,6 +490,7 @@ FetchBody(struct sess *sp, struct object *obj) ...@@ -487,6 +490,7 @@ FetchBody(struct sess *sp, struct object *obj)
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
w = sp->wrk; w = sp->wrk;
AZ(w->fetch_obj);
CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(obj->http, HTTP_MAGIC); CHECK_OBJ_NOTNULL(obj->http, HTTP_MAGIC);
...@@ -498,6 +502,9 @@ FetchBody(struct sess *sp, struct object *obj) ...@@ -498,6 +502,9 @@ FetchBody(struct sess *sp, struct object *obj)
AZ(w->vgz_rx); AZ(w->vgz_rx);
AZ(VTAILQ_FIRST(&obj->store)); AZ(VTAILQ_FIRST(&obj->store));
w->fetch_obj = obj;
switch (w->body_status) { switch (w->body_status) {
case BS_NONE: case BS_NONE:
cls = 0; cls = 0;
...@@ -541,6 +548,8 @@ FetchBody(struct sess *sp, struct object *obj) ...@@ -541,6 +548,8 @@ FetchBody(struct sess *sp, struct object *obj)
*/ */
AZ(vfp_nop_end(sp)); AZ(vfp_nop_end(sp));
w->fetch_obj = NULL;
WSL(w, SLT_Fetch_Body, w->vbc->vsl_id, "%u(%s) cls %d mklen %u", WSL(w, SLT_Fetch_Body, w->vbc->vsl_id, "%u(%s) cls %d mklen %u",
w->body_status, body_status(w->body_status), w->body_status, body_status(w->body_status),
cls, mklen); cls, mklen);
......
...@@ -259,7 +259,7 @@ VGZ_ObufStorage(const struct sess *sp, struct vgz *vg) ...@@ -259,7 +259,7 @@ VGZ_ObufStorage(const struct sess *sp, struct vgz *vg)
{ {
struct storage *st; struct storage *st;
st = FetchStorage(sp, 0); st = FetchStorage(sp->wrk, 0);
if (st == NULL) if (st == NULL)
return (-1); return (-1);
...@@ -615,7 +615,7 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes) ...@@ -615,7 +615,7 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AZ(vg->vz.avail_in); AZ(vg->vz.avail_in);
while (bytes > 0) { while (bytes > 0) {
st = FetchStorage(sp, 0); st = FetchStorage(sp->wrk, 0);
if (st == NULL) { if (st == NULL) {
htc->error = "Could not get storage"; htc->error = "Could not get storage";
return (-1); return (-1);
......
...@@ -371,10 +371,10 @@ STV_Freestore(struct object *o) ...@@ -371,10 +371,10 @@ STV_Freestore(struct object *o)
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
struct storage * struct storage *
STV_alloc(struct worker *w, const struct object *obj, size_t size) STV_alloc(struct worker *w, size_t size)
{ {
return (stv_alloc(w, obj, size)); return (stv_alloc(w, w->fetch_obj, size));
} }
void void
......
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