]> err.no Git - varnish/commitdiff
Handle backend connection error in pass mode with a 503
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 23 Aug 2006 07:30:42 +0000 (07:30 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 23 Aug 2006 07:30:42 +0000 (07:30 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@903 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/cache_pass.c

index 5b6b2ae2aa3bf8a28ade9e2d2a3af76dd1fc6cba..56c5098b0d52fc0657feb2ce4d1bf35d55018250 100644 (file)
@@ -368,7 +368,7 @@ void http_DoConnection(struct sess *sp);
 #undef HTTPH
 
 /* cache_pass.c */
-void PassSession(struct sess *sp);
+int PassSession(struct sess *sp);
 void PassBody(struct sess *sp);
 
 /* cache_pipe.c */
index f5a51f6940b691e799c90771e34bd3a1c81f0b72..b6e5af927a441c8918910350453766ccf7dca82e 100644 (file)
@@ -492,9 +492,11 @@ cnt_pass(struct sess *sp)
 {
 
        assert(sp->vbc == NULL);
-       PassSession(sp);
-       assert(sp->vbc != NULL);
-       sp->step = STP_PASSBODY;
+       if (!PassSession(sp)) {
+               assert(sp->vbc != NULL);
+               sp->step = STP_PASSBODY;
+       } else 
+               sp->step = STP_DONE;
        return (0);
 }
 
index 57bc633db3685782e72ed323416b1c42851d8cfb..17d5e44c0a9a76caea1f8cdebe6733f4fde95f44 100644 (file)
@@ -187,7 +187,7 @@ PassBody(struct sess *sp)
 
 /*--------------------------------------------------------------------*/
 
-void
+int
 PassSession(struct sess *sp)
 {
        int i;
@@ -199,6 +199,10 @@ PassSession(struct sess *sp)
        w = sp->wrk;
 
        vc = VBE_GetFd(sp->backend, sp->xid);
+       if (vc == NULL) {
+               RES_Error(sp, 503, "Backend did not respond.");
+               return (1);
+       }
        assert(vc != NULL);
        VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name);
 
@@ -218,4 +222,5 @@ PassSession(struct sess *sp)
 
        assert(sp->vbc == NULL);
        sp->vbc = vc;
+       return (0);
 }