r5214 - in trunk/varnish-cache: bin/varnishd include lib/libvarnishapi
phk at varnish-cache.org
phk at varnish-cache.org
Wed Sep 15 13:20:42 CEST 2010
Author: phk
Date: 2010-09-15 13:20:41 +0200 (Wed, 15 Sep 2010)
New Revision: 5214
Added:
trunk/varnish-cache/include/vsc_all.h
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_pool.c
trunk/varnish-cache/bin/varnishd/mgt_cli.c
trunk/varnish-cache/include/vsc.h
trunk/varnish-cache/include/vsc_fields.h
trunk/varnish-cache/lib/libvarnishapi/vsc.c
Log:
Redo the dynamic stats CPP magic to require less replicated coding when
new structs are added.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2010-09-15 09:04:54 UTC (rev 5213)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2010-09-15 11:20:41 UTC (rev 5214)
@@ -195,11 +195,13 @@
#define L0(n)
#define L1(n) int n;
-#define VSC_F_MAIN(n, t, l, f, e) L##l(n)
+#define VSC_F(n, t, l, f, e) L##l(n)
+#define VSC_DO_MAIN
struct dstat {
#include "vsc_fields.h"
};
-#undef VSC_F_MAIN
+#undef VSC_F
+#undef VSC_DO_MAIN
#undef L0
#undef L1
Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c 2010-09-15 09:04:54 UTC (rev 5213)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2010-09-15 11:20:41 UTC (rev 5214)
@@ -96,9 +96,11 @@
Lck_AssertHeld(&wstat_mtx);
#define L0(n)
#define L1(n) (VSC_main->n += w->stats.n)
-#define VSC_F_MAIN(n, t, l, f, d) L##l(n);
+#define VSC_DO_MAIN
+#define VSC_F(n, t, l, f, d) L##l(n);
#include "vsc_fields.h"
-#undef VSC_F_MAIN
+#undef VSC_F
+#undef VSC_DO_MAIN
#undef L0
#undef L1
memset(&w->stats, 0, sizeof w->stats);
Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-09-15 09:04:54 UTC (rev 5213)
+++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-09-15 11:20:41 UTC (rev 5214)
@@ -81,11 +81,13 @@
(void)priv;
AN(VSC_main);
-#define VSC_F_MAIN(n, t, l, f, d) \
+#define VSC_DO_MAIN
+#define VSC_F(n, t, l, f, d) \
if (VSC_main->n != 0) \
cli_out(cli, "%12ju %s\n", (VSC_main->n), d);
#include "vsc_fields.h"
-#undef VSC_F_MAIN
+#undef VSC_F
+#undef VSC_DO_MAIN
}
/*--------------------------------------------------------------------*/
Modified: trunk/varnish-cache/include/vsc.h
===================================================================
--- trunk/varnish-cache/include/vsc.h 2010-09-15 09:04:54 UTC (rev 5213)
+++ trunk/varnish-cache/include/vsc.h 2010-09-15 11:20:41 UTC (rev 5214)
@@ -34,33 +34,17 @@
#define VSC_CLASS "Stat"
#define VSC_TYPE_MAIN ""
-
-struct vsc_main {
-#define VSC_F_MAIN(n, t, l, f, e) t n;
-#include "vsc_fields.h"
-#undef VSC_F_MAIN
-};
-
#define VSC_TYPE_SMA "SMA"
-
-struct vsc_sma {
-#define VSC_F_SMA(n, t, l, f, e) t n;
-#include "vsc_fields.h"
-#undef VSC_F_SMA
-};
-
#define VSC_TYPE_VBE "VBE"
+#define VSC_TYPE_LCK "LCK"
-struct vsc_vbe {
-#define VSC_F_VBE(n, t, l, f, e) t n;
-#include "vsc_fields.h"
-#undef VSC_F_VBE
-};
+#define VSC_F(n, t, l, f, e) t n;
-#define VSC_TYPE_LCK "LCK"
+#define VSC_DO(u,l,t) struct vsc_##l {
+#define VSC_DONE(u,l,t) };
-struct vsc_lck {
-#define VSC_F_LCK(n, t, l, f, e) t n;
-#include "vsc_fields.h"
-#undef VSC_F_LCK
-};
+#include "vsc_all.h"
+
+#undef VSC_DO
+#undef VSC_F
+#undef VSC_DONE
Added: trunk/varnish-cache/include/vsc_all.h
===================================================================
--- trunk/varnish-cache/include/vsc_all.h (rev 0)
+++ trunk/varnish-cache/include/vsc_all.h 2010-09-15 11:20:41 UTC (rev 5214)
@@ -0,0 +1,54 @@
+/*-
+ * Copyright (c) 2010 Linpro 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.
+ *
+ * $Id$
+ */
+
+
+VSC_DO(MAIN, main, VSC_TYPE_MAIN)
+#define VSC_DO_MAIN
+#include "vsc_fields.h"
+#undef VSC_DO_MAIN
+VSC_DONE(MAIN, main, VSC_TYPE_MAIN)
+
+VSC_DO(SMA, sma, VSC_TYPE_SMA)
+#define VSC_DO_SMA
+#include "vsc_fields.h"
+#undef VSC_DO_SMA
+VSC_DONE(SMA, sma, VSC_TYPE_SMA)
+
+VSC_DO(VBE, vbe, VSC_TYPE_VBE)
+#define VSC_DO_VBE
+#include "vsc_fields.h"
+#undef VSC_DO_VBE
+VSC_DONE(VBE, vbe, VSC_TYPE_VBE)
+
+VSC_DO(LCK, lck, VSC_TYPE_LCK)
+#define VSC_DO_LCK
+#include "vsc_fields.h"
+#undef VSC_DO_LCK
+VSC_DONE(LCK, lck, VSC_TYPE_LCK)
Modified: trunk/varnish-cache/include/vsc_fields.h
===================================================================
--- trunk/varnish-cache/include/vsc_fields.h 2010-09-15 09:04:54 UTC (rev 5213)
+++ trunk/varnish-cache/include/vsc_fields.h 2010-09-15 11:20:41 UTC (rev 5214)
@@ -33,189 +33,166 @@
*/
/**********************************************************************/
-#ifndef VSC_F_MAIN
-#define VSC_F_MAIN(a, b, c, d, e)
-#define __VSC_F_MAIN
-#endif
-VSC_F_MAIN(client_conn, uint64_t, 0, 'a', "Client connections accepted")
-VSC_F_MAIN(client_drop, uint64_t, 0, 'a',
+#ifdef VSC_DO_MAIN
+
+VSC_F(client_conn, uint64_t, 0, 'a', "Client connections accepted")
+VSC_F(client_drop, uint64_t, 0, 'a',
"Connection dropped, no sess/wrk")
-VSC_F_MAIN(client_req, uint64_t, 1, 'a', "Client requests received")
+VSC_F(client_req, uint64_t, 1, 'a', "Client requests received")
-VSC_F_MAIN(cache_hit, uint64_t, 1, 'a', "Cache hits")
-VSC_F_MAIN(cache_hitpass, uint64_t, 1, 'a', "Cache hits for pass")
-VSC_F_MAIN(cache_miss, uint64_t, 1, 'a', "Cache misses")
+VSC_F(cache_hit, uint64_t, 1, 'a', "Cache hits")
+VSC_F(cache_hitpass, uint64_t, 1, 'a', "Cache hits for pass")
+VSC_F(cache_miss, uint64_t, 1, 'a', "Cache misses")
-VSC_F_MAIN(backend_conn, uint64_t, 0, 'a', "Backend conn. success")
-VSC_F_MAIN(backend_unhealthy, uint64_t, 0, 'a', "Backend conn. not attempted")
-VSC_F_MAIN(backend_busy, uint64_t, 0, 'a', "Backend conn. too many")
-VSC_F_MAIN(backend_fail, uint64_t, 0, 'a', "Backend conn. failures")
-VSC_F_MAIN(backend_reuse, uint64_t, 0, 'a', "Backend conn. reuses")
-VSC_F_MAIN(backend_toolate, uint64_t, 0, 'a', "Backend conn. was closed")
-VSC_F_MAIN(backend_recycle, uint64_t, 0, 'a', "Backend conn. recycles")
-VSC_F_MAIN(backend_unused, uint64_t, 0, 'a', "Backend conn. unused")
-VSC_F_MAIN(backend_retry, uint64_t, 0, 'a', "Backend conn. retry")
+VSC_F(backend_conn, uint64_t, 0, 'a', "Backend conn. success")
+VSC_F(backend_unhealthy, uint64_t, 0, 'a', "Backend conn. not attempted")
+VSC_F(backend_busy, uint64_t, 0, 'a', "Backend conn. too many")
+VSC_F(backend_fail, uint64_t, 0, 'a', "Backend conn. failures")
+VSC_F(backend_reuse, uint64_t, 0, 'a', "Backend conn. reuses")
+VSC_F(backend_toolate, uint64_t, 0, 'a', "Backend conn. was closed")
+VSC_F(backend_recycle, uint64_t, 0, 'a', "Backend conn. recycles")
+VSC_F(backend_unused, uint64_t, 0, 'a', "Backend conn. unused")
+VSC_F(backend_retry, uint64_t, 0, 'a', "Backend conn. retry")
-VSC_F_MAIN(fetch_head, uint64_t, 1, 'a', "Fetch head")
-VSC_F_MAIN(fetch_length, uint64_t, 1, 'a', "Fetch with Length")
-VSC_F_MAIN(fetch_chunked, uint64_t, 1, 'a', "Fetch chunked")
-VSC_F_MAIN(fetch_eof, uint64_t, 1, 'a', "Fetch EOF")
-VSC_F_MAIN(fetch_bad, uint64_t, 1, 'a', "Fetch had bad headers")
-VSC_F_MAIN(fetch_close, uint64_t, 1, 'a', "Fetch wanted close")
-VSC_F_MAIN(fetch_oldhttp, uint64_t, 1, 'a', "Fetch pre HTTP/1.1 closed")
-VSC_F_MAIN(fetch_zero, uint64_t, 1, 'a', "Fetch zero len")
-VSC_F_MAIN(fetch_failed, uint64_t, 1, 'a', "Fetch failed")
+VSC_F(fetch_head, uint64_t, 1, 'a', "Fetch head")
+VSC_F(fetch_length, uint64_t, 1, 'a', "Fetch with Length")
+VSC_F(fetch_chunked, uint64_t, 1, 'a', "Fetch chunked")
+VSC_F(fetch_eof, uint64_t, 1, 'a', "Fetch EOF")
+VSC_F(fetch_bad, uint64_t, 1, 'a', "Fetch had bad headers")
+VSC_F(fetch_close, uint64_t, 1, 'a', "Fetch wanted close")
+VSC_F(fetch_oldhttp, uint64_t, 1, 'a', "Fetch pre HTTP/1.1 closed")
+VSC_F(fetch_zero, uint64_t, 1, 'a', "Fetch zero len")
+VSC_F(fetch_failed, uint64_t, 1, 'a', "Fetch failed")
-VSC_F_MAIN(n_sess_mem, uint64_t, 0, 'i', "N struct sess_mem")
-VSC_F_MAIN(n_sess, uint64_t, 0, 'i', "N struct sess")
-VSC_F_MAIN(n_object, uint64_t, 1, 'i', "N struct object")
-VSC_F_MAIN(n_vampireobject, uint64_t, 1, 'i', "N unresurrected objects")
-VSC_F_MAIN(n_objectcore, uint64_t, 1, 'i', "N struct objectcore")
-VSC_F_MAIN(n_objecthead, uint64_t, 1, 'i', "N struct objecthead")
-VSC_F_MAIN(n_smf, uint64_t, 0, 'i', "N struct smf")
-VSC_F_MAIN(n_smf_frag, uint64_t, 0, 'i', "N small free smf")
-VSC_F_MAIN(n_smf_large, uint64_t, 0, 'i', "N large free smf")
-VSC_F_MAIN(n_vbc, uint64_t, 0, 'i', "N struct vbc")
-VSC_F_MAIN(n_wrk, uint64_t, 0, 'i', "N worker threads")
-VSC_F_MAIN(n_wrk_create, uint64_t, 0, 'a', "N worker threads created")
-VSC_F_MAIN(n_wrk_failed, uint64_t, 0, 'a',
+VSC_F(n_sess_mem, uint64_t, 0, 'i', "N struct sess_mem")
+VSC_F(n_sess, uint64_t, 0, 'i', "N struct sess")
+VSC_F(n_object, uint64_t, 1, 'i', "N struct object")
+VSC_F(n_vampireobject, uint64_t, 1, 'i', "N unresurrected objects")
+VSC_F(n_objectcore, uint64_t, 1, 'i', "N struct objectcore")
+VSC_F(n_objecthead, uint64_t, 1, 'i', "N struct objecthead")
+VSC_F(n_smf, uint64_t, 0, 'i', "N struct smf")
+VSC_F(n_smf_frag, uint64_t, 0, 'i', "N small free smf")
+VSC_F(n_smf_large, uint64_t, 0, 'i', "N large free smf")
+VSC_F(n_vbc, uint64_t, 0, 'i', "N struct vbc")
+VSC_F(n_wrk, uint64_t, 0, 'i', "N worker threads")
+VSC_F(n_wrk_create, uint64_t, 0, 'a', "N worker threads created")
+VSC_F(n_wrk_failed, uint64_t, 0, 'a',
"N worker threads not created")
-VSC_F_MAIN(n_wrk_max, uint64_t, 0, 'a', "N worker threads limited")
-VSC_F_MAIN(n_wrk_queue, uint64_t, 0, 'a', "N queued work requests")
-VSC_F_MAIN(n_wrk_overflow, uint64_t, 0, 'a', "N overflowed work requests")
-VSC_F_MAIN(n_wrk_drop, uint64_t, 0, 'a', "N dropped work requests")
-VSC_F_MAIN(n_backend, uint64_t, 0, 'i', "N backends")
+VSC_F(n_wrk_max, uint64_t, 0, 'a', "N worker threads limited")
+VSC_F(n_wrk_queue, uint64_t, 0, 'a', "N queued work requests")
+VSC_F(n_wrk_overflow, uint64_t, 0, 'a', "N overflowed work requests")
+VSC_F(n_wrk_drop, uint64_t, 0, 'a', "N dropped work requests")
+VSC_F(n_backend, uint64_t, 0, 'i', "N backends")
-VSC_F_MAIN(n_expired, uint64_t, 0, 'i', "N expired objects")
-VSC_F_MAIN(n_lru_nuked, uint64_t, 0, 'i', "N LRU nuked objects")
-VSC_F_MAIN(n_lru_saved, uint64_t, 0, 'i', "N LRU saved objects")
-VSC_F_MAIN(n_lru_moved, uint64_t, 0, 'i', "N LRU moved objects")
-VSC_F_MAIN(n_deathrow, uint64_t, 0, 'i', "N objects on deathrow")
+VSC_F(n_expired, uint64_t, 0, 'i', "N expired objects")
+VSC_F(n_lru_nuked, uint64_t, 0, 'i', "N LRU nuked objects")
+VSC_F(n_lru_saved, uint64_t, 0, 'i', "N LRU saved objects")
+VSC_F(n_lru_moved, uint64_t, 0, 'i', "N LRU moved objects")
+VSC_F(n_deathrow, uint64_t, 0, 'i', "N objects on deathrow")
-VSC_F_MAIN(losthdr, uint64_t, 0, 'a', "HTTP header overflows")
+VSC_F(losthdr, uint64_t, 0, 'a', "HTTP header overflows")
-VSC_F_MAIN(n_objsendfile, uint64_t, 0, 'a', "Objects sent with sendfile")
-VSC_F_MAIN(n_objwrite, uint64_t, 0, 'a', "Objects sent with write")
-VSC_F_MAIN(n_objoverflow, uint64_t, 1, 'a',
+VSC_F(n_objsendfile, uint64_t, 0, 'a', "Objects sent with sendfile")
+VSC_F(n_objwrite, uint64_t, 0, 'a', "Objects sent with write")
+VSC_F(n_objoverflow, uint64_t, 1, 'a',
"Objects overflowing workspace")
-VSC_F_MAIN(s_sess, uint64_t, 1, 'a', "Total Sessions")
-VSC_F_MAIN(s_req, uint64_t, 1, 'a', "Total Requests")
-VSC_F_MAIN(s_pipe, uint64_t, 1, 'a', "Total pipe")
-VSC_F_MAIN(s_pass, uint64_t, 1, 'a', "Total pass")
-VSC_F_MAIN(s_fetch, uint64_t, 1, 'a', "Total fetch")
-VSC_F_MAIN(s_hdrbytes, uint64_t, 1, 'a', "Total header bytes")
-VSC_F_MAIN(s_bodybytes, uint64_t, 1, 'a', "Total body bytes")
+VSC_F(s_sess, uint64_t, 1, 'a', "Total Sessions")
+VSC_F(s_req, uint64_t, 1, 'a', "Total Requests")
+VSC_F(s_pipe, uint64_t, 1, 'a', "Total pipe")
+VSC_F(s_pass, uint64_t, 1, 'a', "Total pass")
+VSC_F(s_fetch, uint64_t, 1, 'a', "Total fetch")
+VSC_F(s_hdrbytes, uint64_t, 1, 'a', "Total header bytes")
+VSC_F(s_bodybytes, uint64_t, 1, 'a', "Total body bytes")
-VSC_F_MAIN(sess_closed, uint64_t, 1, 'a', "Session Closed")
-VSC_F_MAIN(sess_pipeline, uint64_t, 1, 'a', "Session Pipeline")
-VSC_F_MAIN(sess_readahead, uint64_t, 1, 'a', "Session Read Ahead")
-VSC_F_MAIN(sess_linger, uint64_t, 1, 'a', "Session Linger")
-VSC_F_MAIN(sess_herd, uint64_t, 1, 'a', "Session herd")
+VSC_F(sess_closed, uint64_t, 1, 'a', "Session Closed")
+VSC_F(sess_pipeline, uint64_t, 1, 'a', "Session Pipeline")
+VSC_F(sess_readahead, uint64_t, 1, 'a', "Session Read Ahead")
+VSC_F(sess_linger, uint64_t, 1, 'a', "Session Linger")
+VSC_F(sess_herd, uint64_t, 1, 'a', "Session herd")
-VSC_F_MAIN(shm_records, uint64_t, 0, 'a', "SHM records")
-VSC_F_MAIN(shm_writes, uint64_t, 0, 'a', "SHM writes")
-VSC_F_MAIN(shm_flushes, uint64_t, 0, 'a', "SHM flushes due to overflow")
-VSC_F_MAIN(shm_cont, uint64_t, 0, 'a', "SHM MTX contention")
-VSC_F_MAIN(shm_cycles, uint64_t, 0, 'a', "SHM cycles through buffer")
+VSC_F(shm_records, uint64_t, 0, 'a', "SHM records")
+VSC_F(shm_writes, uint64_t, 0, 'a', "SHM writes")
+VSC_F(shm_flushes, uint64_t, 0, 'a', "SHM flushes due to overflow")
+VSC_F(shm_cont, uint64_t, 0, 'a', "SHM MTX contention")
+VSC_F(shm_cycles, uint64_t, 0, 'a', "SHM cycles through buffer")
-VSC_F_MAIN(sm_nreq, uint64_t, 0, 'a', "allocator requests")
-VSC_F_MAIN(sm_nobj, uint64_t, 0, 'i', "outstanding allocations")
-VSC_F_MAIN(sm_balloc, uint64_t, 0, 'i', "bytes allocated")
-VSC_F_MAIN(sm_bfree, uint64_t, 0, 'i', "bytes free")
+VSC_F(sm_nreq, uint64_t, 0, 'a', "allocator requests")
+VSC_F(sm_nobj, uint64_t, 0, 'i', "outstanding allocations")
+VSC_F(sm_balloc, uint64_t, 0, 'i', "bytes allocated")
+VSC_F(sm_bfree, uint64_t, 0, 'i', "bytes free")
-VSC_F_MAIN(sms_nreq, uint64_t, 0, 'a', "SMS allocator requests")
-VSC_F_MAIN(sms_nobj, uint64_t, 0, 'i', "SMS outstanding allocations")
-VSC_F_MAIN(sms_nbytes, uint64_t, 0, 'i', "SMS outstanding bytes")
-VSC_F_MAIN(sms_balloc, uint64_t, 0, 'i', "SMS bytes allocated")
-VSC_F_MAIN(sms_bfree, uint64_t, 0, 'i', "SMS bytes freed")
+VSC_F(sms_nreq, uint64_t, 0, 'a', "SMS allocator requests")
+VSC_F(sms_nobj, uint64_t, 0, 'i', "SMS outstanding allocations")
+VSC_F(sms_nbytes, uint64_t, 0, 'i', "SMS outstanding bytes")
+VSC_F(sms_balloc, uint64_t, 0, 'i', "SMS bytes allocated")
+VSC_F(sms_bfree, uint64_t, 0, 'i', "SMS bytes freed")
-VSC_F_MAIN(backend_req, uint64_t, 0, 'a', "Backend requests made")
+VSC_F(backend_req, uint64_t, 0, 'a', "Backend requests made")
-VSC_F_MAIN(n_vcl, uint64_t, 0, 'a', "N vcl total")
-VSC_F_MAIN(n_vcl_avail, uint64_t, 0, 'a', "N vcl available")
-VSC_F_MAIN(n_vcl_discard, uint64_t, 0, 'a', "N vcl discarded")
+VSC_F(n_vcl, uint64_t, 0, 'a', "N vcl total")
+VSC_F(n_vcl_avail, uint64_t, 0, 'a', "N vcl available")
+VSC_F(n_vcl_discard, uint64_t, 0, 'a', "N vcl discarded")
-VSC_F_MAIN(n_purge, uint64_t, 0, 'i', "N total active purges")
-VSC_F_MAIN(n_purge_add, uint64_t, 0, 'a', "N new purges added")
-VSC_F_MAIN(n_purge_retire, uint64_t, 0, 'a', "N old purges deleted")
-VSC_F_MAIN(n_purge_obj_test, uint64_t, 0, 'a', "N objects tested")
-VSC_F_MAIN(n_purge_re_test, uint64_t, 0, 'a', "N regexps tested against")
-VSC_F_MAIN(n_purge_dups, uint64_t, 0, 'a', "N duplicate purges removed")
+VSC_F(n_purge, uint64_t, 0, 'i', "N total active purges")
+VSC_F(n_purge_add, uint64_t, 0, 'a', "N new purges added")
+VSC_F(n_purge_retire, uint64_t, 0, 'a', "N old purges deleted")
+VSC_F(n_purge_obj_test, uint64_t, 0, 'a', "N objects tested")
+VSC_F(n_purge_re_test, uint64_t, 0, 'a', "N regexps tested against")
+VSC_F(n_purge_dups, uint64_t, 0, 'a', "N duplicate purges removed")
-VSC_F_MAIN(hcb_nolock, uint64_t, 0, 'a', "HCB Lookups without lock")
-VSC_F_MAIN(hcb_lock, uint64_t, 0, 'a', "HCB Lookups with lock")
-VSC_F_MAIN(hcb_insert, uint64_t, 0, 'a', "HCB Inserts")
+VSC_F(hcb_nolock, uint64_t, 0, 'a', "HCB Lookups without lock")
+VSC_F(hcb_lock, uint64_t, 0, 'a', "HCB Lookups with lock")
+VSC_F(hcb_insert, uint64_t, 0, 'a', "HCB Inserts")
-VSC_F_MAIN(esi_parse, uint64_t, 0, 'a', "Objects ESI parsed (unlock)")
-VSC_F_MAIN(esi_errors, uint64_t, 0, 'a', "ESI parse errors (unlock)")
-VSC_F_MAIN(accept_fail, uint64_t, 0, 'a', "Accept failures")
-VSC_F_MAIN(client_drop_late, uint64_t, 0, 'a', "Connection dropped late")
-VSC_F_MAIN(uptime, uint64_t, 0, 'a', "Client uptime")
+VSC_F(esi_parse, uint64_t, 0, 'a', "Objects ESI parsed (unlock)")
+VSC_F(esi_errors, uint64_t, 0, 'a', "ESI parse errors (unlock)")
+VSC_F(accept_fail, uint64_t, 0, 'a', "Accept failures")
+VSC_F(client_drop_late, uint64_t, 0, 'a', "Connection dropped late")
+VSC_F(uptime, uint64_t, 0, 'a', "Client uptime")
-VSC_F_MAIN(dir_dns_lookups, uint64_t, 0, 'a', "DNS director lookups")
-VSC_F_MAIN(dir_dns_failed, uint64_t, 0, 'a', "DNS director failed lookups")
-VSC_F_MAIN(dir_dns_hit, uint64_t, 0, 'a', "DNS director cached lookups hit")
-VSC_F_MAIN(dir_dns_cache_full, uint64_t, 0, 'a', "DNS director full dnscache")
+VSC_F(dir_dns_lookups, uint64_t, 0, 'a', "DNS director lookups")
+VSC_F(dir_dns_failed, uint64_t, 0, 'a', "DNS director failed lookups")
+VSC_F(dir_dns_hit, uint64_t, 0, 'a', "DNS director cached lookups hit")
+VSC_F(dir_dns_cache_full, uint64_t, 0, 'a', "DNS director full dnscache")
-VSC_F_MAIN(critbit_cooler, uint64_t, 0, 'i', "Objhdr's on cool list")
+VSC_F(critbit_cooler, uint64_t, 0, 'i', "Objhdr's on cool list")
-VSC_F_MAIN(vmods, uint64_t, 0, 'i', "Loaded VMODs")
+VSC_F(vmods, uint64_t, 0, 'i', "Loaded VMODs")
-#ifdef __VSC_F_MAIN
-#undef VSC_F_MAIN
-#undef __VSC_F_MAIN
#endif
/**********************************************************************/
-#ifndef VSC_F_SMA
-#define VSC_F_SMA(a, b, c, d, e)
-#define __VSC_F_SMA
-#endif
+#ifdef VSC_DO_SMA
-VSC_F_SMA(sma_nreq, uint64_t, 0, 'a', "Allocator requests")
-VSC_F_SMA(sma_nobj, uint64_t, 0, 'i', "Outstanding allocations")
-VSC_F_SMA(sma_nbytes, uint64_t, 0, 'i', "Outstanding bytes")
-VSC_F_SMA(sma_balloc, uint64_t, 0, 'i', "Bytes allocated")
-VSC_F_SMA(sma_bfree, uint64_t, 0, 'i', "Bytes free")
+VSC_F(sma_nreq, uint64_t, 0, 'a', "Allocator requests")
+VSC_F(sma_nobj, uint64_t, 0, 'i', "Outstanding allocations")
+VSC_F(sma_nbytes, uint64_t, 0, 'i', "Outstanding bytes")
+VSC_F(sma_balloc, uint64_t, 0, 'i', "Bytes allocated")
+VSC_F(sma_bfree, uint64_t, 0, 'i', "Bytes free")
-#ifdef __VSC_F_SMA
-#undef VSC_F_SMA
-#undef __VSC_F_SMA
#endif
/**********************************************************************/
-#ifndef VSC_F_VBE
-#define VSC_F_VBE(a, b, c, d, e)
-#define __VSC_F_VBE
-#endif
+#ifdef VSC_DO_VBE
-VSC_F_VBE(vcls, uint64_t, 0, 'i', "VCL references")
-VSC_F_VBE(happy, uint64_t, 0, 'b', "Happy health probes")
+VSC_F(vcls, uint64_t, 0, 'i', "VCL references")
+VSC_F(happy, uint64_t, 0, 'b', "Happy health probes")
-#ifdef __VSC_F_VBE
-#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
+#ifdef VSC_DO_LCK
-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")
+VSC_F(creat, uint64_t, 0, 'a', "Created locks")
+VSC_F(destroy, uint64_t, 0, 'a', "Destroyed locks")
+VSC_F(locks, uint64_t, 0, 'a', "Lock Operations")
+VSC_F(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 09:04:54 UTC (rev 5213)
+++ trunk/varnish-cache/lib/libvarnishapi/vsc.c 2010-09-15 11:20:41 UTC (rev 5214)
@@ -283,118 +283,40 @@
return (func(priv, sp));
}
-static int
-iter_main(const struct vsc *vsc, struct vsm_chunk *sha, vsc_iter_f *func,
- void *priv)
-{
- struct vsc_main *st;
- struct vsc_point sp;
- int i;
+#define VSC_DO(U,l,t) \
+ static int \
+ iter_##l(const struct vsc *vsc, struct vsm_chunk *sha, \
+ vsc_iter_f *func, void *priv) \
+ { \
+ struct vsc_##l *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 = t; \
+ sp.ident = sha->ident;
- CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC);
- CHECK_OBJ_NOTNULL(sha, VSM_CHUNK_MAGIC);
+#define VSC_F(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);
- st = VSM_PTR(sha);
- sp.class = "";
- sp.ident = "";
-#define VSC_F_MAIN(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_MAIN
- return (0);
-}
+#define VSC_DONE(U,l,t) \
+ return (0); \
+ }
-static int
-iter_sma(const struct vsc *vsc, struct vsm_chunk *sha, vsc_iter_f *func,
- void *priv)
-{
- struct vsc_sma *st;
- struct vsc_point sp;
- int i;
+#include "vsc_all.h"
+#undef VSC_DO
+#undef VSC_F
+#undef VSC_DONE
- CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC);
- CHECK_OBJ_NOTNULL(sha, VSM_CHUNK_MAGIC);
- st = VSM_PTR(sha);
-
- sp.class = VSC_TYPE_SMA;
- sp.ident = sha->ident;
-#define VSC_F_SMA(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_SMA
- return (0);
-}
-
-static int
-iter_vbe(const struct vsc *vsc, struct vsm_chunk *sha, vsc_iter_f *func,
- void *priv)
-{
- struct vsc_vbe *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_VBE;
- sp.ident = sha->ident;
-#define VSC_F_VBE(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_VBE
- 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)
{
@@ -411,18 +333,20 @@
CHECK_OBJ_NOTNULL(sha, VSM_CHUNK_MAGIC);
if (strcmp(sha->class, VSC_CLASS))
continue;
- if (!strcmp(sha->type, VSC_TYPE_MAIN))
- i = iter_main(vsc, sha, func, priv);
- else if (!strcmp(sha->type, VSC_TYPE_SMA))
- 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)
- break;
+
+#define VSC_F(a,b,c,d,e)
+#define VSC_DONE(a,b,c)
+#define VSC_DO(U,l,t) \
+ if (!strcmp(sha->type, t)) { \
+ i = iter_##l(vsc, sha, func, priv); \
+ if (!i) \
+ continue; \
+ }
+#include "vsc_all.h"
+#undef VSC_F
+#undef VSC_DO
+#undef VSC_DONE
+ break;
}
return (i);
}
More information about the varnish-commit
mailing list