[Varnish] #495: HTTP/1.0 or 'Connection: closed' backend race condition

Varnish varnish-bugs at projects.linpro.no
Sat Nov 21 01:38:07 CET 2009

#495: HTTP/1.0 or 'Connection: closed' backend race condition
 Reporter:  cra       |        Owner:  phk  
     Type:  defect    |       Status:  new  
 Priority:  low       |    Milestone:       
Component:  varnishd  |      Version:  trunk
 Severity:  normal    |   Resolution:       
 Keywords:            |  
Comment (by niallohiggins):

 The HTTP/1.1 spec (RFC2608 Section `Negotiation'
 http://www.apps.ietf.org/rfc/rfc2068.html#sec-8.1) seems quite explicit
 about behaviour here:

   Clients and servers SHOULD NOT assume that a persistent connection is
   maintained for HTTP versions less than 1.1 unless it is explicitly
   signaled. See section 19.7.1 for more information on backwards
   compatibility with HTTP/1.0 clients.

 Therefore, I believe the correct thing for Varnish to do if it detects a
 HTTP/1.0 response from an origin server is to disable re-use for that
 connection.  Seeing as Varnish has an existing check for HTTP/1.1
 responses with Connection: Close headers, the patch (against 2.0.5) seems
 to be relatively straightforward:
 --- cache_fetch.c.orig  2009-11-21 00:32:08.302103546 +0000
 +++ cache_fetch.c       2009-11-21 00:32:32.590103329 +0000

 @@ -497,7 +497,8 @@ Fetch(struct sess *sp)
                 http_PrintfHeader(sp->wrk, sp->fd, hp2,
                     "Content-Length: %u", sp->obj->len);

 -       if (http_HdrIs(hp, H_Connection, "close"))
 +       if (http_HdrIs(hp, H_Connection, "close")
 +           || hp->protover < 1.1)
                 cls = 1;

         if (cls)

Ticket URL: <http://varnish.projects.linpro.no/ticket/495#comment:14>
Varnish <http://varnish.projects.linpro.no/>
The Varnish HTTP Accelerator

More information about the varnish-bugs mailing list