From 54bd90e426711c0c01d93509721720af7b3f77fa Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 23 Aug 2006 07:30:42 +0000 Subject: [PATCH] Handle backend connection error in pass mode with a 503 git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@903 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache.h | 2 +- varnish-cache/bin/varnishd/cache_center.c | 8 +++++--- varnish-cache/bin/varnishd/cache_pass.c | 7 ++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 5b6b2ae2..56c5098b 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -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 */ diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index f5a51f69..b6e5af92 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -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); } diff --git a/varnish-cache/bin/varnishd/cache_pass.c b/varnish-cache/bin/varnishd/cache_pass.c index 57bc633d..17d5e44c 100644 --- a/varnish-cache/bin/varnishd/cache_pass.c +++ b/varnish-cache/bin/varnishd/cache_pass.c @@ -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); } -- 2.39.5