From 13d1d0ff6aec9c76186009f1243e24255f0c9d66 Mon Sep 17 00:00:00 2001
From: Dag Haavi Finstad <daghf@varnish-software.com>
Date: Wed, 20 Feb 2013 14:24:46 +0100
Subject: [PATCH] Fixes an issue in backend probe initialization that causes
 the default value of .initial to equal .threshold.

The default for .initial is now .threshold - 1, meaning that the backend
starts up as sick and a single successful poll is required for it to be
considered healthy.

With the previous behaviour, a sick backend would not be considered sick
until after the initial polls exit the polling window.

Thanks to Colin Curtin.

Fixes: #1227
---
 bin/varnishd/cache/cache_backend_poll.c |    2 +-
 doc/sphinx/reference/vcl.rst            |    6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/bin/varnishd/cache/cache_backend_poll.c b/bin/varnishd/cache/cache_backend_poll.c
index ab405f9..4780165 100644
--- a/bin/varnishd/cache/cache_backend_poll.c
+++ b/bin/varnishd/cache/cache_backend_poll.c
@@ -461,7 +461,7 @@ vbp_new_vcl(const struct vrt_backend_probe *p, const char *hosthdr)
 	if (vcl->probe.exp_status == 0)
 		vcl->probe.exp_status = 200;
 
-	if (vcl->probe.threshold == ~0U)
+	if (vcl->probe.initial == ~0U)
 		vcl->probe.initial = vcl->probe.threshold - 1;
 
 	if (vcl->probe.initial > vcl->probe.threshold)
diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst
index 731da16..3aec723 100644
--- a/doc/sphinx/reference/vcl.rst
+++ b/doc/sphinx/reference/vcl.rst
@@ -201,8 +201,10 @@ Probes take the following parameters:
   the backend healthy.
   Defaults to 3.
 .initial
-  How many of the probes are considered good when Varnish starts.
-  Defaults to the same amount as the threshold.
+  How many of the polls in .window are considered good when Varnish
+  starts.  Defaults to the value of threshold - 1. In this case, the
+  backend starts as sick and requires one poll to be considered
+  healthy.
 .expected_response
   The expected backend HTTP response code.
   Defaults to 200.
-- 
1.7.10.4

