[experimental-ims] e91fe76 Fix a buglet where we could send one backends Host: header to another backend under very rare circumstances.
Geoff Simmons
geoff at varnish-cache.org
Mon Jan 9 21:52:47 CET 2012
commit e91fe766effc59fc42bbde821b69552c086c60f3
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Dec 5 13:06:28 2011 +0000
Fix a buglet where we could send one backends Host: header to another
backend under very rare circumstances.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 4cfad78..05aaf39 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -712,7 +712,7 @@ int EXP_NukeOne(struct worker *w, struct lru *lru);
struct storage *FetchStorage(struct worker *w, ssize_t sz);
int FetchError(struct worker *w, const char *error);
int FetchError2(struct worker *w, const char *error, const char *more);
-int FetchHdr(struct sess *sp);
+int FetchHdr(struct sess *sp, int need_host_hdr);
int FetchBody(struct worker *w, struct object *obj);
int FetchReqBody(struct sess *sp);
void Fetch_Init(void);
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 997ecac..d2126ba 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -554,7 +554,7 @@ DOT errfetch [label="ERROR",shape=plaintext]
static int
cnt_fetch(struct sess *sp)
{
- int i;
+ int i, need_host_hdr;
struct worker *wrk;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -571,7 +571,9 @@ cnt_fetch(struct sess *sp)
http_Setup(wrk->beresp, wrk->ws);
- i = FetchHdr(sp);
+ need_host_hdr = !http_GetHdr(wrk->bereq, H_Host, NULL);
+
+ i = FetchHdr(sp, need_host_hdr);
/*
* If we recycle a backend connection, there is a finite chance
* that the backend closed it before we get a request to it.
@@ -579,7 +581,7 @@ cnt_fetch(struct sess *sp)
*/
if (i == 1) {
VSC_C_main->backend_retry++;
- i = FetchHdr(sp);
+ i = FetchHdr(sp, need_host_hdr);
}
if (i) {
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 1d4eff3..7d8763f 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -375,11 +375,10 @@ FetchReqBody(struct sess *sp)
*/
int
-FetchHdr(struct sess *sp)
+FetchHdr(struct sess *sp, int need_host_hdr)
{
struct vbc *vc;
struct worker *w;
- char *b;
struct http *hp;
int retry = -1;
int i;
@@ -415,7 +414,7 @@ FetchHdr(struct sess *sp)
* header if one is necessary. This cannot be done in the VCL
* because the backend may be chosen by a director.
*/
- if (!http_GetHdr(hp, H_Host, &b))
+ if (need_host_hdr)
VDI_AddHostHeader(sp);
(void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */
More information about the varnish-commit
mailing list