From 806d5a8936e77c3adbead723dfa56554125d15fb Mon Sep 17 00:00:00 2001 From: cecilihf Date: Mon, 24 Sep 2007 13:18:04 +0000 Subject: [PATCH] Fixes bug #161. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2012 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_backend.c | 19 ++++++++++++++----- .../bin/varnishd/cache_backend_random.c | 4 ++++ .../bin/varnishd/cache_backend_round_robin.c | 4 ++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_backend.c b/varnish-cache/bin/varnishd/cache_backend.c index cdf34fa7..5becc136 100644 --- a/varnish-cache/bin/varnishd/cache_backend.c +++ b/varnish-cache/bin/varnishd/cache_backend.c @@ -309,16 +309,25 @@ VBE_RecycleFd(struct worker *w, struct vbe_conn *vc) CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC); } -/* Update health ----------------------------------------------*/ - +/* Update health ----------------------------------------------------*/ +/* See cache_backend_random.c and/or cache_backend_round_robin.c for + * details and comments about this function. + */ void VBE_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int a) { struct backend *b; - CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC); - CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC); - b = vc->backend; + if (vc != NULL) { + CHECK_OBJ_NOTNULL(vc, VBE_CONN_MAGIC); + CHECK_OBJ_NOTNULL(vc->backend, BACKEND_MAGIC); + b = vc->backend; + } + else { + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC); + b = sp->backend; + } AN(b->method); if(b->method->updatehealth != NULL) b->method->updatehealth(sp, vc, a); diff --git a/varnish-cache/bin/varnishd/cache_backend_random.c b/varnish-cache/bin/varnishd/cache_backend_random.c index 8a79d2f1..edc10d07 100644 --- a/varnish-cache/bin/varnishd/cache_backend_random.c +++ b/varnish-cache/bin/varnishd/cache_backend_random.c @@ -397,6 +397,10 @@ ber_GetHostname(struct backend *b) /*--------------------------------------------------------------------*/ +/* This should maybe be divided into two separate functions. One for + * increasing/decreasing health, and one for "pulling" the health + * towards neutral (0) as time passes + */ static void ber_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int add) { diff --git a/varnish-cache/bin/varnishd/cache_backend_round_robin.c b/varnish-cache/bin/varnishd/cache_backend_round_robin.c index 882003f7..36f4f842 100644 --- a/varnish-cache/bin/varnishd/cache_backend_round_robin.c +++ b/varnish-cache/bin/varnishd/cache_backend_round_robin.c @@ -382,6 +382,10 @@ brr_GetHostname(struct backend *b) /*--------------------------------------------------------------------*/ +/* This should maybe be divided into two separate functions. One for + * increasing/decreasing health, and one for "pulling" the health + * towards neutral (0) as time passes + */ static void brr_UpdateHealth(struct sess *sp, struct vbe_conn *vc, int add) { -- 2.39.5