commit 66685fd48e60cdc63105806e522a0d8e043d43ba
Author: Martin Blix Grydeland <martin@varnish-software.com>
Date:   Tue Aug 2 13:41:10 2011 +0200

    Do not retry a backend connection if we have ever read any of the
    request body bytes.
    
    If we were to retry this, the next try will surely fail as there isn't
    Content-Length bytes available to read from the requesting client,
    making the 2nd backend connection futile.
    
    This problem was spotted while looking into #968, though not directly
    related to it.

diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index a875071..21ae6eb 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -711,7 +711,7 @@ int EXP_NukeOne(const struct sess *sp, struct lru *lru);
 struct storage *FetchStorage(const struct sess *sp, ssize_t sz);
 int FetchHdr(struct sess *sp);
 int FetchBody(struct sess *sp);
-int FetchReqBody(struct sess *sp);
+int FetchReqBody(struct sess *sp, int *retry);
 void Fetch_Init(void);
 
 /* cache_gzip.c */
diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 23ad92f..34f0d28 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -966,7 +966,7 @@ cnt_hit(struct sess *sp)
 
 	if (sp->handling == VCL_RET_DELIVER) {
 		/* Dispose of any body part of the request */
-		(void)FetchReqBody(sp);
+		(void)FetchReqBody(sp, NULL);
 		AZ(sp->wrk->bereq->ws);
 		AZ(sp->wrk->beresp->ws);
 		sp->step = STP_PREPRESP;
diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c
index 1063c6b..dfa4940 100644
--- a/bin/varnishd/cache_fetch.c
+++ b/bin/varnishd/cache_fetch.c
@@ -329,7 +329,7 @@ fetch_eof(struct sess *sp, struct http_conn *htc)
  */
 
 int
-FetchReqBody(struct sess *sp)
+FetchReqBody(struct sess *sp, int *retry)
 {
 	unsigned long content_length;
 	char buf[8192];
@@ -341,6 +341,8 @@ FetchReqBody(struct sess *sp)
 		content_length = strtoul(ptr, &endp, 10);
 		/* XXX should check result of conversion */
 		while (content_length) {
+			if (retry != NULL)
+				*retry = -1;
 			if (content_length > sizeof buf)
 				rdcnt = sizeof buf;
 			else
@@ -420,7 +422,7 @@ FetchHdr(struct sess *sp)
 	(void)http_Write(w, hp, 0);	/* XXX: stats ? */
 
 	/* Deal with any message-body the request might have */
-	i = FetchReqBody(sp);
+	i = FetchReqBody(sp, &retry);
 	if (WRW_FlushRelease(w) || i > 0) {
 		WSP(sp, SLT_FetchError, "backend write error: %d (%s)",
 		    errno, strerror(errno));
