Commit 3999568c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Shave some session from FetchBody

parent 8c80f864
...@@ -702,7 +702,7 @@ int EXP_NukeOne(struct worker *w, struct lru *lru); ...@@ -702,7 +702,7 @@ 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(const struct sess *sp, ssize_t sz);
int FetchHdr(struct sess *sp); int FetchHdr(struct sess *sp);
int FetchBody(struct sess *sp); int FetchBody(struct sess *sp, struct object *obj);
int FetchReqBody(struct sess *sp); int FetchReqBody(struct sess *sp);
void Fetch_Init(void); void Fetch_Init(void);
......
...@@ -846,7 +846,7 @@ cnt_fetchbody(struct sess *sp) ...@@ -846,7 +846,7 @@ cnt_fetchbody(struct sess *sp)
} }
/* Use unmodified headers*/ /* Use unmodified headers*/
i = FetchBody(sp); i = FetchBody(sp, sp->obj);
sp->wrk->h_content_length = NULL; sp->wrk->h_content_length = NULL;
...@@ -910,7 +910,7 @@ cnt_streambody(struct sess *sp) ...@@ -910,7 +910,7 @@ cnt_streambody(struct sess *sp)
AssertObjCorePassOrBusy(sp->obj->objcore); AssertObjCorePassOrBusy(sp->obj->objcore);
i = FetchBody(sp); i = FetchBody(sp, sp->obj);
sp->wrk->h_content_length = NULL; sp->wrk->h_content_length = NULL;
......
...@@ -477,7 +477,7 @@ FetchHdr(struct sess *sp) ...@@ -477,7 +477,7 @@ FetchHdr(struct sess *sp)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
int int
FetchBody(struct sess *sp) FetchBody(struct sess *sp, struct object *obj)
{ {
int cls; int cls;
struct storage *st; struct storage *st;
...@@ -487,17 +487,17 @@ FetchBody(struct sess *sp) ...@@ -487,17 +487,17 @@ FetchBody(struct sess *sp)
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;
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(sp->obj->http, HTTP_MAGIC); CHECK_OBJ_NOTNULL(obj->http, HTTP_MAGIC);
if (w->vfp == NULL) if (w->vfp == NULL)
w->vfp = &vfp_nop; w->vfp = &vfp_nop;
AN(sp->director); AN(sp->director);
AssertObjCorePassOrBusy(sp->obj->objcore); AssertObjCorePassOrBusy(obj->objcore);
AZ(w->vgz_rx); AZ(w->vgz_rx);
AZ(VTAILQ_FIRST(&sp->obj->store)); AZ(VTAILQ_FIRST(&obj->store));
switch (w->body_status) { switch (w->body_status) {
case BS_NONE: case BS_NONE:
cls = 0; cls = 0;
...@@ -541,57 +541,57 @@ FetchBody(struct sess *sp) ...@@ -541,57 +541,57 @@ FetchBody(struct sess *sp)
*/ */
AZ(vfp_nop_end(sp)); AZ(vfp_nop_end(sp));
WSL(w, SLT_Fetch_Body, sp->wrk->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);
if (w->body_status == BS_ERROR) { if (w->body_status == BS_ERROR) {
VDI_CloseFd(sp->wrk); VDI_CloseFd(w);
return (__LINE__); return (__LINE__);
} }
if (cls < 0) { if (cls < 0) {
w->stats.fetch_failed++; w->stats.fetch_failed++;
/* XXX: Wouldn't this store automatically be released ? */ /* XXX: Wouldn't this store automatically be released ? */
while (!VTAILQ_EMPTY(&sp->obj->store)) { while (!VTAILQ_EMPTY(&obj->store)) {
st = VTAILQ_FIRST(&sp->obj->store); st = VTAILQ_FIRST(&obj->store);
VTAILQ_REMOVE(&sp->obj->store, st, list); VTAILQ_REMOVE(&obj->store, st, list);
STV_free(st); STV_free(st);
} }
VDI_CloseFd(sp->wrk); VDI_CloseFd(w);
sp->obj->len = 0; obj->len = 0;
return (__LINE__); return (__LINE__);
} }
if (cls == 0 && w->do_close) if (cls == 0 && w->do_close)
cls = 1; cls = 1;
WSL(w, SLT_Length, sp->wrk->vbc->vsl_id, "%u", sp->obj->len); WSL(w, SLT_Length, w->vbc->vsl_id, "%u", obj->len);
{ {
/* Sanity check fetch methods accounting */ /* Sanity check fetch methods accounting */
ssize_t uu; ssize_t uu;
uu = 0; uu = 0;
VTAILQ_FOREACH(st, &sp->obj->store, list) VTAILQ_FOREACH(st, &obj->store, list)
uu += st->len; uu += st->len;
if (sp->objcore == NULL || (sp->objcore->flags & OC_F_PASS)) if (sp->objcore == NULL || (sp->objcore->flags & OC_F_PASS))
/* Streaming might have started freeing stuff */ /* Streaming might have started freeing stuff */
assert (uu <= sp->obj->len); assert (uu <= obj->len);
else else
assert(uu == sp->obj->len); assert(uu == obj->len);
} }
if (mklen > 0) { if (mklen > 0) {
http_Unset(sp->obj->http, H_Content_Length); http_Unset(obj->http, H_Content_Length);
http_PrintfHeader(w, sp->vsl_id, sp->obj->http, http_PrintfHeader(w, sp->vsl_id, obj->http,
"Content-Length: %jd", (intmax_t)sp->obj->len); "Content-Length: %jd", (intmax_t)obj->len);
} }
if (cls) if (cls)
VDI_CloseFd(sp->wrk); VDI_CloseFd(w);
else else
VDI_RecycleFd(sp->wrk); VDI_RecycleFd(w);
return (0); return (0);
} }
......
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