[master] 44a3513 Hide struct dstat from vmods.
Poul-Henning Kamp
phk at FreeBSD.org
Sat May 27 10:58:06 CEST 2017
commit 44a35137598a342f9967f844891fa8151906574c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sat May 27 07:41:24 2017 +0000
Hide struct dstat from vmods.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 5256c3f..70ee5f1 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -250,18 +250,6 @@ struct acct_bereq {
/*--------------------------------------------------------------------*/
-#define L0(t, n)
-#define L1(t, n) t n;
-#define VSC_FF(n,t,l,s,f,v,d,e) L##l(t, n)
-struct dstat {
- unsigned summs;
-#include "tbl/vsc_f_main.h"
-};
-#undef L0
-#undef L1
-
-/*--------------------------------------------------------------------*/
-
struct vsl_log {
uint32_t *wlb, *wlp, *wle;
unsigned wlr;
@@ -315,7 +303,7 @@ struct worker {
struct objhead *nobjhead;
struct objcore *nobjcore;
void *nhashpriv;
- struct dstat stats[1];
+ struct dstat *stats;
struct vsl_log *vsl; // borrowed from req/bo
struct pool_task task;
@@ -860,8 +848,8 @@ void *MPL_Get(struct mempool *mpl, unsigned *size);
void MPL_Free(struct mempool *mpl, void *item);
/* cache_obj.c */
-struct objcore * ObjNew(struct worker *);
-void ObjDestroy(struct worker *, struct objcore **);
+struct objcore * ObjNew(const struct worker *);
+void ObjDestroy(const struct worker *, struct objcore **);
typedef int objiterate_f(void *priv, int flush, const void *ptr, ssize_t len);
int ObjIterate(struct worker *, struct objcore *,
void *priv, objiterate_f *func, int final);
@@ -920,8 +908,8 @@ const char *sess_close_2str(enum sess_close sc, int want_desc);
int Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio);
int Pool_Task_Arg(struct worker *, enum task_prio, task_func_t *,
const void *arg, size_t arg_len);
-void Pool_Sumstat(struct worker *w);
-int Pool_TrySumstat(struct worker *wrk);
+void Pool_Sumstat(const struct worker *w);
+int Pool_TrySumstat(const struct worker *wrk);
void Pool_PurgeStat(unsigned nobj);
int Pool_Task_Any(struct pool_task *task, enum task_prio prio);
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 6dd6e61..986af6f 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -72,7 +72,8 @@ struct rush {
static const struct hash_slinger *hash;
static struct objhead *private_oh;
-static void hsh_rush1(struct worker *, struct objhead *, struct rush *, int);
+static void hsh_rush1(const struct worker *, struct objhead *,
+ struct rush *, int);
static void hsh_rush2(struct worker *, struct rush *);
/*---------------------------------------------------------------------*/
@@ -116,7 +117,7 @@ hsh_prealloc(struct worker *wrk)
/*---------------------------------------------------------------------*/
struct objcore *
-HSH_Private(struct worker *wrk)
+HSH_Private(const struct worker *wrk)
{
struct objcore *oc;
@@ -156,7 +157,7 @@ HSH_Cleanup(struct worker *wrk)
}
void
-HSH_DeleteObjHead(struct worker *wrk, struct objhead *oh)
+HSH_DeleteObjHead(const struct worker *wrk, struct objhead *oh)
{
AZ(oh->refcnt);
@@ -529,7 +530,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
*/
static void
-hsh_rush1(struct worker *wrk, struct objhead *oh, struct rush *r, int max)
+hsh_rush1(const struct worker *wrk, struct objhead *oh, struct rush *r, int max)
{
unsigned u;
struct req *req;
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index cf7b708..a139bcf 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -132,7 +132,7 @@ obj_deleteboc(struct boc **p)
*/
struct objcore *
-ObjNew(struct worker *wrk)
+ObjNew(const struct worker *wrk)
{
struct objcore *oc;
@@ -155,7 +155,7 @@ ObjNew(struct worker *wrk)
*/
void
-ObjDestroy(struct worker *wrk, struct objcore **p)
+ObjDestroy(const struct worker *wrk, struct objcore **p)
{
struct objcore *oc;
diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c
index 671ceca..6f8ba29 100644
--- a/bin/varnishd/cache/cache_pool.c
+++ b/bin/varnishd/cache/cache_pool.c
@@ -64,7 +64,7 @@ pool_sumstat(const struct dstat *src)
}
void
-Pool_Sumstat(struct worker *wrk)
+Pool_Sumstat(const struct worker *wrk)
{
Lck_Lock(&wstat_mtx);
@@ -74,7 +74,7 @@ Pool_Sumstat(struct worker *wrk)
}
int
-Pool_TrySumstat(struct worker *wrk)
+Pool_TrySumstat(const struct worker *wrk)
{
if (Lck_Trylock(&wstat_mtx))
return (0);
diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h
index 215ebc9..d83629a 100644
--- a/bin/varnishd/cache/cache_priv.h
+++ b/bin/varnishd/cache/cache_priv.h
@@ -31,6 +31,18 @@
#include "VSC_main.h"
+/*--------------------------------------------------------------------*/
+
+#define L0(t, n)
+#define L1(t, n) t n;
+#define VSC_FF(n,t,l,s,f,v,d,e) L##l(t, n)
+struct dstat {
+ unsigned summs;
+#include "tbl/vsc_f_main.h"
+};
+#undef L0
+#undef L1
+
/* Prototypes etc ----------------------------------------------------*/
/* cache_acceptor.c */
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index f3dfc3b..be38c8d 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -61,10 +61,13 @@ wrk_bgthread(void *arg)
{
struct bgthread *bt;
struct worker wrk;
+ struct dstat ds;
CAST_OBJ_NOTNULL(bt, arg, BGTHREAD_MAGIC);
THR_SetName(bt->name);
INIT_OBJ(&wrk, WORKER_MAGIC);
+ memset(&ds, 0, sizeof ds);
+ wrk.stats = &ds;
(void)bt->func(&wrk, bt->priv);
@@ -93,6 +96,7 @@ static void
WRK_Thread(struct pool *qp, size_t stacksize, unsigned thread_workspace)
{
struct worker *w, ww;
+ struct dstat ds;
unsigned char ws[thread_workspace];
uintptr_t u;
@@ -104,6 +108,8 @@ WRK_Thread(struct pool *qp, size_t stacksize, unsigned thread_workspace)
w = &ww;
INIT_OBJ(w, WORKER_MAGIC);
w->lastused = NAN;
+ memset(&ds, 0, sizeof ds);
+ w->stats = &ds;
AZ(pthread_cond_init(&w->cond, NULL));
WS_Init(w->aws, "wrk", ws, thread_workspace);
diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h
index 006cab5..92f9a72 100644
--- a/bin/varnishd/hash/hash_slinger.h
+++ b/bin/varnishd/hash/hash_slinger.h
@@ -74,7 +74,7 @@ void HSH_Purge(struct worker *, struct objhead *, double ttl, double grace,
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(struct worker *wrk);
+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 *);
@@ -107,7 +107,7 @@ struct objhead {
void HSH_Fail(struct objcore *);
void HSH_Unbusy(struct worker *, struct objcore *);
-void HSH_DeleteObjHead(struct worker *, struct objhead *);
+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
diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c
index 780df0d..36aa348 100644
--- a/bin/varnishd/storage/storage_persistent_silo.c
+++ b/bin/varnishd/storage/storage_persistent_silo.c
@@ -389,7 +389,7 @@ smp_loaded_st(const struct smp_sc *sc, const struct smp_seg *sg,
* objcore methods for persistent objects
*/
-struct object *
+struct object * __match_proto__(sml_getobj_f)
smp_sml_getobj(struct worker *wrk, struct objcore *oc)
{
struct object *o;
More information about the varnish-commit
mailing list