[PATCH 02/10] Add a BAN_Shutdown() routine that is called before STV_Close(), and makes sure that the ban lists will not change until we exit.
Martin Blix Grydeland
martin at varnish-software.com
Wed Oct 10 16:27:15 CEST 2012
This is to give persistent stevedores a chance to clean up their ban
lists without having to worry about the lists changing under them
(normally the ban callbacks are called under the ban mutex, but not so
during exit).
This is achieved by locking the ban mutex on BAN_Shutdown(), and never
releasing it again.
---
bin/varnishd/cache/cache.h | 1 +
bin/varnishd/cache/cache_ban.c | 14 ++++++++++++++
bin/varnishd/cache/cache_main.c | 1 +
3 files changed, 16 insertions(+)
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 6d4fe86..49effb2 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -748,6 +748,7 @@ int BAN_AddTest(struct cli *, struct ban *, const char *, const char *,
void BAN_Free(struct ban *b);
void BAN_Insert(struct ban *b);
void BAN_Init(void);
+void BAN_Shutdown(void);
void BAN_NewObjCore(struct objcore *oc);
void BAN_DestroyObj(struct objcore *oc);
int BAN_CheckObject(struct object *o, struct req *sp);
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index aa8bca9..1e7cce8 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -1145,3 +1145,17 @@ BAN_Init(void)
VSC_C_main->bans_gone++;
BAN_Insert(ban_magic);
}
+
+/*
+ * Take the ban_mtx and return, preventing any BAN functions from succeeding.
+ *
+ * This is called before STV_close to allow persistent stevedores to
+ * close down without any bans changing (the persistent ban callbacks
+ * are run under the ban_mtx).
+ */
+
+void
+BAN_Shutdown(void)
+{
+ Lck_Lock(&ban_mtx);
+}
diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c
index ac36308..d30f92c 100644
--- a/bin/varnishd/cache/cache_main.c
+++ b/bin/varnishd/cache/cache_main.c
@@ -230,6 +230,7 @@ child_main(void)
CLI_Run();
+ BAN_Shutdown();
STV_close();
printf("Child dies\n");
--
1.7.9.5
More information about the varnish-dev
mailing list