Commit 62e111be authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Tighten up the object fetch code a little bit.

parent c5e69db8
......@@ -631,7 +631,7 @@ int EXP_NukeOne(const struct sess *sp, const struct lru *lru);
/* cache_fetch.c */
struct storage *FetchStorage(const struct sess *sp, ssize_t sz);
int FetchHdr(struct sess *sp);
int FetchBody(struct sess *sp);
int FetchBody(struct sess *sp, struct http *hp);
int FetchReqBody(struct sess *sp);
void Fetch_Init(void);
......
......@@ -573,22 +573,11 @@ cnt_fetch(struct sess *sp)
* had one.
*/
if (sp->wrk->cacheable) {
CHECK_OBJ_NOTNULL(sp->objcore, OBJCORE_MAGIC);
vary = VRY_Create(sp, sp->wrk->beresp);
if (vary != NULL) {
varyl = vsb_len(vary);
assert(varyl > 0);
}
} else {
AZ(sp->objcore);
}
AZ(sp->wrk->vfp);
/*
* The VCL variables beresp.do_g[un]zip tells us how we want the
* object stored.
* object processed before it is stored.
*
* The backend Content-Encoding header tells us what we are going
* to receive, which we classify in the following three classes:
......@@ -645,8 +634,16 @@ cnt_fetch(struct sess *sp)
l = http_EstimateWS(sp->wrk->beresp,
sp->pass ? HTTPH_R_PASS : HTTPH_A_INS, &nhttp);
if (vary != NULL)
/* Create Vary instructions */
if (sp->wrk->cacheable) {
CHECK_OBJ_NOTNULL(sp->objcore, OBJCORE_MAGIC);
vary = VRY_Create(sp, sp->wrk->beresp);
if (vary != NULL) {
varyl = vsb_len(vary);
assert(varyl > 0);
l += varyl;
}
}
/*
* Space for producing a Content-Length: header including padding
......@@ -654,10 +651,6 @@ cnt_fetch(struct sess *sp)
*/
l += strlen("Content-Encoding: XxxXxxXxxXxxXxxXxx" + sizeof(void *));
/*
* XXX: VFP's may affect estimate
*/
sp->obj = STV_NewObject(sp, sp->wrk->storage_hint, l,
sp->wrk->ttl, nhttp);
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
......@@ -700,7 +693,13 @@ cnt_fetch(struct sess *sp)
else
sp->obj->last_modified = sp->wrk->entered;
i = FetchBody(sp);
/* Use unmodified headers*/
i = FetchBody(sp, sp->wrk->beresp1);
sp->wrk->bereq = NULL;
sp->wrk->beresp = NULL;
sp->wrk->beresp1 = NULL;
sp->wrk->vfp = NULL;
AZ(sp->wrk->wfd);
AZ(sp->vbc);
......@@ -709,9 +708,6 @@ cnt_fetch(struct sess *sp)
if (i) {
HSH_Drop(sp);
AZ(sp->obj);
sp->wrk->bereq = NULL;
sp->wrk->beresp = NULL;
sp->wrk->beresp1 = NULL;
sp->err_code = 503;
sp->step = STP_ERROR;
return (0);
......@@ -722,9 +718,6 @@ cnt_fetch(struct sess *sp)
HSH_Drop(sp);
sp->director = NULL;
sp->restarts++;
sp->wrk->bereq = NULL;
sp->wrk->beresp = NULL;
sp->wrk->beresp1 = NULL;
sp->step = STP_RECV;
return (0);
case VCL_RET_PASS:
......@@ -737,9 +730,6 @@ cnt_fetch(struct sess *sp)
break;
case VCL_RET_ERROR:
HSH_Drop(sp);
sp->wrk->bereq = NULL;
sp->wrk->beresp = NULL;
sp->wrk->beresp1 = NULL;
sp->step = STP_ERROR;
return (0);
default:
......@@ -754,9 +744,6 @@ cnt_fetch(struct sess *sp)
HSH_Unbusy(sp);
}
sp->acct_tmp.fetch++;
sp->wrk->bereq = NULL;
sp->wrk->beresp = NULL;
sp->wrk->beresp1 = NULL;
sp->step = STP_DELIVER;
return (0);
}
......
......@@ -481,11 +481,10 @@ FetchHdr(struct sess *sp)
/*--------------------------------------------------------------------*/
int
FetchBody(struct sess *sp)
FetchBody(struct sess *sp, struct http *hp)
{
char *b;
int cls;
struct http *hp;
struct storage *st;
int mklen;
......@@ -497,8 +496,6 @@ FetchBody(struct sess *sp)
if (sp->wrk->vfp == NULL)
sp->wrk->vfp = &vfp_nop;
/* We use the unmodified headers */
hp = sp->wrk->beresp1;
AN(sp->director);
AssertObjPassOrBusy(sp->obj);
......
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