[4.1] c153c93 Make it possible to creat LCK classes at runtime.
Lasse Karstensen
lkarsten at varnish-software.com
Thu Jan 14 15:15:09 CET 2016
commit c153c9320ac66d523dc9cf8e03a2e44c0ca1e278
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Dec 16 23:04:42 2015 +0000
Make it possible to creat LCK classes at runtime.
Use the hash_classic class as proof of concept
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 84eef1d..6c6a6ef 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -831,6 +831,8 @@ int Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double);
#define Lck_Trylock(a) Lck__Trylock(a, __func__, __LINE__)
#define Lck_AssertHeld(a) Lck__Assert(a, 1)
+struct VSC_C_lck *Lck_CreateClass(const char *name);
+
#define LOCK(nam) extern struct VSC_C_lck *lck_##nam;
#include "tbl/locks.h"
#undef LOCK
diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c
index f1cea24..b702c2f 100644
--- a/bin/varnishd/cache/cache_lck.c
+++ b/bin/varnishd/cache/cache_lck.c
@@ -212,6 +212,7 @@ Lck__New(struct lock *lck, struct VSC_C_lck *st, const char *w)
struct ilck *ilck;
AN(st);
+ AN(w);
AZ(lck->priv);
ALLOC_OBJ(ilck, ILCK_MAGIC);
AN(ilck);
@@ -234,6 +235,13 @@ Lck_Delete(struct lock *lck)
FREE_OBJ(ilck);
}
+struct VSC_C_lck *
+Lck_CreateClass(const char *name)
+{
+ return(VSM_Alloc(sizeof(struct VSC_C_lck),
+ VSC_CLASS, VSC_type_lck, name));
+}
+
#define LOCK(nam) struct VSC_C_lck *lck_##nam;
#include "tbl/locks.h"
#undef LOCK
@@ -246,9 +254,7 @@ LCK_Init(void)
#if !defined(__APPLE__) && !defined(__MACH__)
AZ(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK));
#endif
-#define LOCK(nam) \
- lck_##nam = VSM_Alloc(sizeof(struct VSC_C_lck), \
- VSC_CLASS, VSC_type_lck, #nam);
+#define LOCK(nam) lck_##nam = Lck_CreateClass(#nam);
#include "tbl/locks.h"
#undef LOCK
}
diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c
index ef817ea..29fffd9 100644
--- a/bin/varnishd/hash/hash_classic.c
+++ b/bin/varnishd/hash/hash_classic.c
@@ -38,6 +38,8 @@
#include "hash/hash_slinger.h"
+static struct VSC_C_lck *lck_hcl;
+
/*--------------------------------------------------------------------*/
struct hcl_hd {
@@ -90,6 +92,7 @@ hcl_start(void)
{
unsigned u;
+ lck_hcl = Lck_CreateClass("hcl");
hcl_head = calloc(sizeof *hcl_head, hcl_nhash);
XXXAN(hcl_head);
diff --git a/include/tbl/locks.h b/include/tbl/locks.h
index 8fe77fe..16af3ac 100644
--- a/include/tbl/locks.h
+++ b/include/tbl/locks.h
@@ -35,7 +35,6 @@ LOCK(busyobj)
LOCK(cli)
LOCK(exp)
LOCK(hcb)
-LOCK(hcl)
LOCK(hsl)
LOCK(lru)
LOCK(mempool)
More information about the varnish-commit
mailing list