[master] 9d91bcc Give objhead its own include separate from the nuts&bolts of hash slingers.

Poul-Henning Kamp phk at FreeBSD.org
Thu Sep 28 08:53:06 UTC 2017


commit 9d91bcca79a3125c852ee429e4d86342bfd2eb21
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Sep 28 08:51:33 2017 +0000

    Give objhead its own include separate from the nuts&bolts of hash slingers.

diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am
index b0b0b05..1d60d91 100644
--- a/bin/varnishd/Makefile.am
+++ b/bin/varnishd/Makefile.am
@@ -116,6 +116,7 @@ noinst_HEADERS = \
 	cache/cache_ban.h \
 	cache/cache_esi.h \
 	cache/cache_obj.h \
+	cache/cache_objhead.h \
 	cache/cache_pool.h \
 	cache/cache_transport.h \
 	cache/cache_varnishd.h \
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 8caac84..e2b16ee 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -34,8 +34,8 @@
 
 #include "cache_varnishd.h"
 #include "cache_ban.h"
+#include "cache_objhead.h"
 
-#include "hash/hash_slinger.h"
 #include "vcli_serve.h"
 #include "vend.h"
 #include "vmb.h"
diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c
index f721394..ba3447e 100644
--- a/bin/varnishd/cache/cache_ban_lurker.c
+++ b/bin/varnishd/cache/cache_ban_lurker.c
@@ -31,9 +31,10 @@
 #include "config.h"
 
 #include "cache_varnishd.h"
+
 #include "cache_ban.h"
+#include "cache_objhead.h"
 
-#include "hash/hash_slinger.h"
 #include "vtim.h"
 
 static struct objcore oc_mark_cnt = { .magic = OBJCORE_MAGIC, };
diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c
index bb13378..b7c9947 100644
--- a/bin/varnishd/cache/cache_busyobj.c
+++ b/bin/varnishd/cache/cache_busyobj.c
@@ -37,7 +37,7 @@
 
 #include "cache_varnishd.h"
 
-#include "hash/hash_slinger.h"
+#include "cache_objhead.h"
 
 static struct mempool		*vbopool;
 
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index 2648c06..a9b7a7e 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -35,9 +35,9 @@
 #include <stdlib.h>
 
 #include "cache_varnishd.h"
+#include "cache_objhead.h"
 
 #include "binary_heap.h"
-#include "hash/hash_slinger.h"
 #include "vtim.h"
 
 struct exp_priv {
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 7efc8b0..ca8c89c 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -32,6 +32,7 @@
 #include "cache_varnishd.h"
 #include "cache_director.h"
 #include "cache_filter.h"
+#include "cache_objhead.h"
 #include "hash/hash_slinger.h"
 #include "storage/storage.h"
 #include "vrt.h"
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 8f1c79b..004b86d 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -52,14 +52,16 @@
 
 #include "config.h"
 
-#include "cache_varnishd.h"
-
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "cache_varnishd.h"
+
+#include "cache/cache_objhead.h"
 #include "cache/cache_transport.h"
 
 #include "hash/hash_slinger.h"
+
 #include "vsha256.h"
 #include "vtim.h"
 
diff --git a/bin/varnishd/cache/cache_objhead.h b/bin/varnishd/cache/cache_objhead.h
new file mode 100644
index 0000000..f4b7055
--- /dev/null
+++ b/bin/varnishd/cache/cache_objhead.h
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 2006 Verdens Gang AS
+ * Copyright (c) 2006-2015 Varnish Software AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+struct hash_slinger;
+
+struct objhead {
+	unsigned		magic;
+#define OBJHEAD_MAGIC		0x1b96615d
+
+	int			refcnt;
+	struct lock		mtx;
+	VTAILQ_HEAD(,objcore)	objcs;
+	uint8_t			digest[DIGEST_LEN];
+	VTAILQ_HEAD(, req)	waitinglist;
+
+	/*----------------------------------------------------
+	 * The fields below are for the sole private use of
+	 * the hash implementation(s).
+	 */
+	union {
+		struct {
+			VTAILQ_ENTRY(objhead)	u_n_hoh_list;
+			void			*u_n_hoh_head;
+		} n;
+	} _u;
+#define hoh_list _u.n.u_n_hoh_list
+#define hoh_head _u.n.u_n_hoh_head
+};
+
+void HSH_Fail(struct objcore *);
+void HSH_Kill(struct objcore *);
+void HSH_Insert(struct worker *, const void *hash, struct objcore *,
+    struct ban *);
+void HSH_Unbusy(struct worker *, struct objcore *);
+int HSH_Snipe(const struct worker *, struct objcore *);
+struct boc *HSH_RefBoc(const struct objcore *);
+void HSH_DerefBoc(struct worker *wrk, struct objcore *);
+void HSH_DeleteObjHead(const struct worker *, struct objhead *);
+int HSH_DerefObjHead(struct worker *, struct objhead **);
+
+int HSH_DerefObjCore(struct worker *, struct objcore **, int rushmax);
+#define HSH_RUSH_POLICY -1
+#define HSH_RUSH_ALL	INT_MAX
+
+enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **,
+    int always_insert);
+void HSH_Ref(struct objcore *o);
+void HSH_AddString(struct req *, void *ctx, const char *str);
+unsigned HSH_Purge(struct worker *, struct objhead *, double ttl, double grace,
+    double keep);
+struct objcore *HSH_Private(const struct worker *wrk);
+void HSH_Abandon(struct objcore *oc);
diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c
index 0ddac6b..b7de15a 100644
--- a/bin/varnishd/cache/cache_req_body.c
+++ b/bin/varnishd/cache/cache_req_body.c
@@ -34,10 +34,12 @@
 
 #include "cache_varnishd.h"
 #include "cache_filter.h"
+#include "cache_objhead.h"
+#include "cache_transport.h"
+
 #include "vtim.h"
-#include "hash/hash_slinger.h"
 #include "storage/storage.h"
-#include "cache_transport.h"
+#include "hash/hash_slinger.h"
 
 /*----------------------------------------------------------------------
  * Pull the req.body in via/into a objcore
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 8625d69..987f3d0 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -41,6 +41,7 @@
 #include "cache_varnishd.h"
 #include "cache_director.h"
 #include "cache_filter.h"
+#include "cache_objhead.h"
 #include "cache_transport.h"
 
 #include "hash/hash_slinger.h"
diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
index c85a452..ca00a44 100644
--- a/bin/varnishd/cache/cache_varnishd.h
+++ b/bin/varnishd/cache/cache_varnishd.h
@@ -44,13 +44,6 @@
 #include "VSC_main.h"
 
 /* -------------------------------------------------------------------*/
-/*
- * This macro can be used in .h files to isolate bits that the manager
- * should not (need to) see, such as pthread mutexes etc.
- */
-#define VARNISH_CACHE_CHILD	1
-
-/* -------------------------------------------------------------------*/
 
 struct vfp;
 
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 79fd1ba..e1766c4 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -34,7 +34,7 @@
 #include "cache_varnishd.h"
 
 #include "cache_director.h"
-#include "hash/hash_slinger.h"
+#include "cache_objhead.h"
 #include "vav.h"
 #include "vrt.h"
 #include "vcl.h"
diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c
index 781dce7..c9e0d7f 100644
--- a/bin/varnishd/hash/hash_classic.c
+++ b/bin/varnishd/hash/hash_classic.c
@@ -31,12 +31,13 @@
 
 #include "config.h"
 
-#include "cache/cache_varnishd.h"
-#include "common/heritage.h"
-
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "cache/cache_varnishd.h"
+#include "cache/cache_objhead.h"
+#include "common/heritage.h"
+
 #include "hash/hash_slinger.h"
 
 static struct VSC_lck *lck_hcl;
diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c
index e548965..417673c 100644
--- a/bin/varnishd/hash/hash_critbit.c
+++ b/bin/varnishd/hash/hash_critbit.c
@@ -35,6 +35,7 @@
 #include <stdlib.h>
 
 #include "cache/cache_varnishd.h"
+#include "cache/cache_objhead.h"
 
 #include "hash/hash_slinger.h"
 #include "vmb.h"
diff --git a/bin/varnishd/hash/hash_simple_list.c b/bin/varnishd/hash/hash_simple_list.c
index 16b3e70..188c5ce 100644
--- a/bin/varnishd/hash/hash_simple_list.c
+++ b/bin/varnishd/hash/hash_simple_list.c
@@ -32,6 +32,7 @@
 #include "config.h"
 
 #include "cache/cache_varnishd.h"
+#include "cache/cache_objhead.h"
 
 #include "hash/hash_slinger.h"
 
diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h
index 3d86c20..d6cad78 100644
--- a/bin/varnishd/hash/hash_slinger.h
+++ b/bin/varnishd/hash/hash_slinger.h
@@ -28,17 +28,15 @@
  *
  */
 
-struct sess;
-struct req;
-struct objcore;
 struct worker;
+struct objhead;
 
 typedef void hash_init_f(int ac, char * const *av);
 typedef void hash_start_f(void);
 typedef void hash_prep_f(struct worker *);
-typedef struct objhead *hash_lookup_f(struct worker *wrk, const void *digest,
-    struct objhead **nobj);
-typedef int hash_deref_f(struct objhead *obj);
+typedef struct objhead *hash_lookup_f(struct worker *, const void *digest,
+    struct objhead **);
+typedef int hash_deref_f(struct objhead *);
 
 struct hash_slinger {
 	unsigned		magic;
@@ -59,60 +57,12 @@ enum lookup_e {
 	HSH_EXPBUSY
 };
 
-/* cache_hash.c */
-struct ban;
-void HSH_Cleanup(struct worker *w);
-enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **,
-    int always_insert);
-void HSH_Ref(struct objcore *o);
-void HSH_Init(const struct hash_slinger *slinger);
-void HSH_AddString(struct req *, void *ctx, const char *str);
-void HSH_Insert(struct worker *, const void *hash, struct objcore *,
-    struct ban *);
-unsigned HSH_Purge(struct worker *, struct objhead *, double ttl, double grace,
-    double keep);
-void HSH_config(const char *h_arg);
-struct boc *HSH_RefBoc(const struct objcore *);
-void HSH_DerefBoc(struct worker *wrk, struct objcore *);
-struct objcore *HSH_Private(const struct worker *wrk);
-void HSH_Abandon(struct objcore *oc);
-int HSH_Snipe(const struct worker *, struct objcore *);
-void HSH_Kill(struct objcore *);
-
-#ifdef VARNISH_CACHE_CHILD
-
-struct objhead {
-	unsigned		magic;
-#define OBJHEAD_MAGIC		0x1b96615d
+/* mgt_hash.c */
+void HSH_config(const char *);
 
-	int			refcnt;
-	struct lock		mtx;
-	VTAILQ_HEAD(,objcore)	objcs;
-	uint8_t			digest[DIGEST_LEN];
-	VTAILQ_HEAD(, req)	waitinglist;
-
-	/*----------------------------------------------------
-	 * The fields below are for the sole private use of
-	 * the hash implementation(s).
-	 */
-	union {
-		struct {
-			VTAILQ_ENTRY(objhead)	u_n_hoh_list;
-			void			*u_n_hoh_head;
-		} n;
-	} _u;
-#define hoh_list _u.n.u_n_hoh_list
-#define hoh_head _u.n.u_n_hoh_head
-};
-
-void HSH_Fail(struct objcore *);
-void HSH_Unbusy(struct worker *, struct objcore *);
-void HSH_DeleteObjHead(const struct worker *, struct objhead *);
-int HSH_DerefObjHead(struct worker *, struct objhead **);
-int HSH_DerefObjCore(struct worker *, struct objcore **, int);
-#define HSH_RUSH_POLICY -1
-#define HSH_RUSH_ALL	INT_MAX
-#endif /* VARNISH_CACHE_CHILD */
+/* cache_hash.c */
+void HSH_Init(const struct hash_slinger *);
+void HSH_Cleanup(struct worker *);
 
 extern const struct hash_slinger hsl_slinger;
 extern const struct hash_slinger hcl_slinger;
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index b694623..58748d3 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -39,9 +39,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "cache/cache_objhead.h"
 #include "cache/cache_transport.h"
 #include "cache_http1.h"
-#include "hash/hash_slinger.h"
 
 #include "vtcp.h"
 
diff --git a/bin/varnishd/storage/storage_lru.c b/bin/varnishd/storage/storage_lru.c
index 4374c58..32d142e 100644
--- a/bin/varnishd/storage/storage_lru.c
+++ b/bin/varnishd/storage/storage_lru.c
@@ -33,7 +33,7 @@
 #include <stdlib.h>
 
 #include "cache/cache_varnishd.h"
-#include "hash/hash_slinger.h"
+#include "cache/cache_objhead.h"
 
 #include "storage/storage.h"
 
diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index 72dd6de..bfc082a 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -43,10 +43,10 @@
 #include <stdlib.h>
 
 #include "cache/cache_obj.h"
+#include "cache/cache_objhead.h"
 #include "storage/storage.h"
 #include "storage/storage_simple.h"
 
-#include "hash/hash_slinger.h"
 #include "vcli_serve.h"
 #include "vsha256.h"
 #include "vtim.h"
diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c
index bacf18e..6718065 100644
--- a/bin/varnishd/storage/storage_persistent_silo.c
+++ b/bin/varnishd/storage/storage_persistent_silo.c
@@ -34,19 +34,20 @@
 
 #include "config.h"
 
-#include "cache/cache_varnishd.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "storage/storage.h"
-#include "storage/storage_simple.h"
+#include "cache/cache_varnishd.h"
 
-#include "hash/hash_slinger.h"
 #include "vsha256.h"
 #include "vend.h"
 #include "vtim.h"
 
+#include "cache/cache_objhead.h"
+
+#include "storage/storage.h"
+#include "storage/storage_simple.h"
 #include "storage/storage_persistent.h"
 
 /*
diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c
index 2716159..38e21f2 100644
--- a/bin/varnishd/storage/storage_simple.c
+++ b/bin/varnishd/storage/storage_simple.c
@@ -32,7 +32,7 @@
 #include "cache/cache_varnishd.h"
 
 #include "cache/cache_obj.h"
-#include "hash/hash_slinger.h"
+#include "cache/cache_objhead.h"
 
 #include "storage/storage.h"
 #include "storage/storage_simple.h"


More information about the varnish-commit mailing list