Making progress on dynamic backends testing, I found a glitch in the
max_connections handling, among other issues.

Patch discussed with fgs and phk, not yet reviewed.

Best Regards,
Dridi
From 07e84dfbd5446583634dd1350be51cbc237fa28c Mon Sep 17 00:00:00 2001
From: Dridi Boukelmoune <[email protected]>
Date: Mon, 29 Jun 2015 17:54:13 +0200
Subject: [PATCH] Decrement backend counters on a connection close

Only the backend's refcount and n_conn are decremented when a connection
is closed. Recycling a connection also means decrementing n_conn, since
connection pools may be shared by several backends (same endpoints). The
max_connections configuration is per-backend, and a recycled connection
may be reused by another backend.

When a backend is deleted, we also check that its refcount is nul.
---
 bin/varnishd/cache/cache_backend.c     | 2 ++
 bin/varnishd/cache/cache_backend_cfg.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 7ed2673..d4308a2 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -189,6 +189,8 @@ vbe_dir_finish(const struct director *d, struct worker *wrk,
 #define ACCT(foo)	bp->vsc->foo += bo->acct.foo;
 #include "tbl/acct_fields_bereq.h"
 #undef ACCT
+	bp->refcount--;
+	bp->n_conn--;
 	Lck_Unlock(&bp->mtx);
 	bo->htc = NULL;
 }
diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c
index 7291cd4..671eb60 100644
--- a/bin/varnishd/cache/cache_backend_cfg.c
+++ b/bin/varnishd/cache/cache_backend_cfg.c
@@ -159,7 +159,9 @@ VBE_Event(struct backend *be, enum vcl_event_e ev)
 void
 VBE_Delete(struct backend *be)
 {
+
 	CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC);
+	AZ(be->refcount);
 
 	if (be->probe != NULL)
 		VBP_Remove(be);
-- 
2.1.0

_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to