r1634 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Tue Jul 3 22:59:27 CEST 2007
Author: phk
Date: 2007-07-03 22:59:27 +0200 (Tue, 03 Jul 2007)
New Revision: 1634
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_fetch.c
Log:
Move bereq backwards into cache_center.c for Fetch cases (Pass, Miss)
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2007-07-03 20:49:42 UTC (rev 1633)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2007-07-03 20:59:27 UTC (rev 1634)
@@ -318,6 +318,7 @@
TAILQ_ENTRY(sess) list;
struct backend *backend;
+ struct bereq *bereq;
struct object *obj;
struct VCL_conf *vcl;
Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2007-07-03 20:49:42 UTC (rev 1633)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2007-07-03 20:59:27 UTC (rev 1634)
@@ -278,8 +278,32 @@
static int
cnt_fetch(struct sess *sp)
{
+ struct bereq *bereq;
+ struct http *hp;
+ char *b;
+ int i;
- if (Fetch(sp)) {
+ 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 (i) {
SYN_ErrorPage(sp, 503, "Error talking to backend", 30);
} else {
RFC2616_cache_policy(sp, &sp->obj->http); /* XXX -> VCL */
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-07-03 20:49:42 UTC (rev 1633)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2007-07-03 20:59:27 UTC (rev 1634)
@@ -270,32 +270,19 @@
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 @@
VBE_ClosedFd(sp->wrk, vc, 0);
else
VBE_RecycleFd(sp->wrk, vc);
- vbe_free_bereq(bereq);
return (0);
}
More information about the varnish-commit
mailing list