r5212 - in trunk/varnish-cache: include lib/libvarnishapi
phk at varnish-cache.org
phk at varnish-cache.org
Wed Sep 15 10:53:26 CEST 2010
Author: phk
Date: 2010-09-15 10:53:25 +0200 (Wed, 15 Sep 2010)
New Revision: 5212
Modified:
trunk/varnish-cache/include/vsc.h
trunk/varnish-cache/include/vsc_fields.h
trunk/varnish-cache/lib/libvarnishapi/vsc.c
Log:
Add a dynamic stats structure for lock information
Modified: trunk/varnish-cache/include/vsc.h
===================================================================
--- trunk/varnish-cache/include/vsc.h 2010-09-15 07:54:50 UTC (rev 5211)
+++ trunk/varnish-cache/include/vsc.h 2010-09-15 08:53:25 UTC (rev 5212)
@@ -56,3 +56,11 @@
#include "vsc_fields.h"
#undef VSC_F_VBE
};
+
+#define VSC_TYPE_LCK "LCK"
+
+struct vsc_lck {
+#define VSC_F_LCK(n, t, l, f, e) t n;
+#include "vsc_fields.h"
+#undef VSC_F_LCK
+};
Modified: trunk/varnish-cache/include/vsc_fields.h
===================================================================
--- trunk/varnish-cache/include/vsc_fields.h 2010-09-15 07:54:50 UTC (rev 5211)
+++ trunk/varnish-cache/include/vsc_fields.h 2010-09-15 08:53:25 UTC (rev 5212)
@@ -202,3 +202,20 @@
#undef VSC_F_VBE
#undef __VSC_F_VBE
#endif
+
+/**********************************************************************/
+
+#ifndef VSC_F_LCK
+#define VSC_F_LCK(a, b, c, d, e)
+#define __VSC_F_LCK
+#endif
+
+VSC_F_LCK(creat, uint64_t, 0, 'a', "Created locks")
+VSC_F_LCK(destroy, uint64_t, 0, 'a', "Destroyed locks")
+VSC_F_LCK(locks, uint64_t, 0, 'a', "Lock Operations")
+VSC_F_LCK(colls, uint64_t, 0, 'a', "Collisions")
+
+#ifdef __VSC_F_LCK
+#undef VSC_F_LCK
+#undef __VSC_F_LCK
+#endif
Modified: trunk/varnish-cache/lib/libvarnishapi/vsc.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsc.c 2010-09-15 07:54:50 UTC (rev 5211)
+++ trunk/varnish-cache/lib/libvarnishapi/vsc.c 2010-09-15 08:53:25 UTC (rev 5212)
@@ -367,6 +367,34 @@
return (0);
}
+static int
+iter_lck(const struct vsc *vsc, struct vsm_chunk *sha, vsc_iter_f *func,
+ void *priv)
+{
+ struct vsc_lck *st;
+ struct vsc_point sp;
+ int i;
+
+ CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC);
+ CHECK_OBJ_NOTNULL(sha, VSM_CHUNK_MAGIC);
+ st = VSM_PTR(sha);
+
+ sp.class = VSC_TYPE_LCK;
+ sp.ident = sha->ident;
+#define VSC_F_LCK(nn, tt, ll, ff, dd) \
+ sp.name = #nn; \
+ sp.fmt = #tt; \
+ sp.flag = ff; \
+ sp.desc = dd; \
+ sp.ptr = &st->nn; \
+ i = iter_call(vsc, func, priv, &sp); \
+ if (i) \
+ return(i);
+#include "vsc_fields.h"
+#undef VSC_F_LCK
+ return (0);
+}
+
int
VSC_Iter(struct VSM_data *vd, vsc_iter_f *func, void *priv)
{
@@ -389,6 +417,8 @@
i = iter_sma(vsc, sha, func, priv);
else if (!strcmp(sha->type, VSC_TYPE_VBE))
i = iter_vbe(vsc, sha, func, priv);
+ else if (!strcmp(sha->type, VSC_TYPE_LCK))
+ i = iter_lck(vsc, sha, func, priv);
else
i = -1;
if (i != 0)
More information about the varnish-commit
mailing list