Commit 94e0d8ba authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move bereq backwards into cache_center.c for Fetch cases (Pass, Miss)


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1634 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent f15124d4
......@@ -318,6 +318,7 @@ struct sess {
TAILQ_ENTRY(sess) list;
struct backend *backend;
struct bereq *bereq;
struct object *obj;
struct VCL_conf *vcl;
......
......@@ -278,8 +278,32 @@ DOT errfetch [label="ERROR",shape=plaintext]
static int
cnt_fetch(struct sess *sp)
{
struct bereq *bereq;
struct http *hp;
char *b;
int i;
bereq = vbe_new_bereq();
AN(bereq);
hp = bereq->http;
hp->logtag = HTTP_Tx;
http_GetReq(sp->wrk, sp->fd, hp, sp->http);
http_FilterHeader(sp->wrk, sp->fd, hp, sp->http, HTTPH_R_FETCH);
http_PrintfHeader(sp->wrk, sp->fd, hp, "X-Varnish: %u", sp->xid);
http_PrintfHeader(sp->wrk, sp->fd, hp,
"X-Forwarded-for: %s", sp->addr);
if (!http_GetHdr(hp, H_Host, &b)) {
http_PrintfHeader(sp->wrk, sp->fd, hp, "Host: %s",
sp->backend->hostname);
}
sp->bereq = bereq;
i = Fetch(sp);
vbe_free_bereq(sp->bereq);
sp->bereq = NULL;
if (Fetch(sp)) {
if (i) {
SYN_ErrorPage(sp, 503, "Error talking to backend", 30);
} else {
RFC2616_cache_policy(sp, &sp->obj->http); /* XXX -> VCL */
......
......@@ -270,32 +270,19 @@ Fetch(struct sess *sp)
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
assert(sp->obj->busy != 0);
w = sp->wrk;
bereq = sp->bereq;
hp = bereq->http;
sp->obj->xid = sp->xid;
vc = VBE_GetFd(sp);
if (vc == NULL)
return (1);
bereq = vbe_new_bereq();
AN(bereq);
hp = bereq->http;
hp->logtag = HTTP_Tx;
http_GetReq(w, vc->fd, hp, sp->http);
http_FilterHeader(w, vc->fd, hp, sp->http, HTTPH_R_FETCH);
http_PrintfHeader(w, vc->fd, hp, "X-Varnish: %u", sp->xid);
http_PrintfHeader(w, vc->fd, hp,
"X-Forwarded-for: %s", sp->addr);
if (!http_GetHdr(hp, H_Host, &b)) {
http_PrintfHeader(w, vc->fd, hp, "Host: %s",
sp->backend->hostname);
}
WRK_Reset(w, &vc->fd);
http_Write(w, hp, 0);
if (WRK_Flush(w)) {
/* XXX: cleanup */
return (1);
}
......@@ -377,7 +364,6 @@ Fetch(struct sess *sp)
VBE_ClosedFd(sp->wrk, vc, 0);
else
VBE_RecycleFd(sp->wrk, vc);
vbe_free_bereq(bereq);
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