r4962 - in trunk/varnish-cache: bin/varnishstat include lib/libvarnishapi

phk at varnish-cache.org phk at varnish-cache.org
Wed Jun 16 12:40:00 CEST 2010


Author: phk
Date: 2010-06-16 12:40:00 +0200 (Wed, 16 Jun 2010)
New Revision: 4962

Modified:
   trunk/varnish-cache/bin/varnishstat/varnishstat.c
   trunk/varnish-cache/bin/varnishstat/varnishstat_curses.c
   trunk/varnish-cache/include/varnishapi.h
   trunk/varnish-cache/lib/libvarnishapi/vsc.c
   trunk/varnish-cache/lib/libvarnishapi/vsm.c
   trunk/varnish-cache/lib/libvarnishapi/vsm_api.h
Log:
Make varnishstat discover dynamic allocations in curses mode.



Modified: trunk/varnish-cache/bin/varnishstat/varnishstat.c
===================================================================
--- trunk/varnish-cache/bin/varnishstat/varnishstat.c	2010-06-16 10:39:33 UTC (rev 4961)
+++ trunk/varnish-cache/bin/varnishstat/varnishstat.c	2010-06-16 10:40:00 UTC (rev 4962)
@@ -74,7 +74,7 @@
 }
 
 static void
-do_xml(const struct VSM_data *vd)
+do_xml(struct VSM_data *vd)
 {
 	char time_stamp[20];
 	time_t now;
@@ -121,7 +121,7 @@
 }
 
 static void
-do_once(const struct VSM_data *vd, const struct vsc_main *VSL_stats)
+do_once(struct VSM_data *vd, const struct vsc_main *VSL_stats)
 {
 	struct once_priv op;
 
@@ -153,7 +153,7 @@
 }
 
 static void
-list_fields(const struct VSM_data *vd)
+list_fields(struct VSM_data *vd)
 {
 	fprintf(stderr, "Varnishstat -f option fields:\n");
 	fprintf(stderr, "Field name                     Description\n");

Modified: trunk/varnish-cache/bin/varnishstat/varnishstat_curses.c
===================================================================
--- trunk/varnish-cache/bin/varnishstat/varnishstat_curses.c	2010-06-16 10:39:33 UTC (rev 4961)
+++ trunk/varnish-cache/bin/varnishstat/varnishstat_curses.c	2010-06-16 10:40:00 UTC (rev 4962)
@@ -100,7 +100,7 @@
 }
 
 static void
-prep_pts(const struct VSM_data *vd)
+prep_pts(struct VSM_data *vd)
 {
 	struct pt *pt, *pt2;
 
@@ -135,6 +135,7 @@
 	int ch, line;
 	struct pt *pt;
 	double act, lact;
+	unsigned seq;
 
 	(void)initscr();
 	AC(raw());
@@ -147,6 +148,7 @@
 		/*
 		 * Initialization goes in outher loop
 		 */
+		seq = VSM_Seq(vd);
 		prep_pts(vd);
 		AC(erase());
 		AC(refresh());
@@ -159,6 +161,8 @@
 		lact = 0;
 
 		while (1) {
+			if (seq != VSM_Seq(vd))
+				break;
 			/*
 			 * Break to outher loop if we need to re-read file.
 			 * Only check if it looks like nothing is happening.

Modified: trunk/varnish-cache/include/varnishapi.h
===================================================================
--- trunk/varnish-cache/include/varnishapi.h	2010-06-16 10:39:33 UTC (rev 4961)
+++ trunk/varnish-cache/include/varnishapi.h	2010-06-16 10:40:00 UTC (rev 4962)
@@ -110,12 +110,17 @@
 	 *	-1 failure to reopen.
 	 */
 
+unsigned VSM_Seq(struct VSM_data *vd);
+	/*
+	 * Return the allocation sequence number
+	 */
+
 struct vsm_head *VSM_Head(const struct VSM_data *vd);
 	/*
 	 * Return the head of the VSM.
 	 */
 
-void *VSM_Find_Chunk(const struct VSM_data *vd, const char *class,
+void *VSM_Find_Chunk(struct VSM_data *vd, const char *class,
     const char *type, const char *ident, unsigned *lenp);
 	/*
 	 * Find a given chunk in the shared memory.
@@ -129,7 +134,7 @@
 	 * Deallocate all storage (including VSC and VSL allocations)
 	 */
 
-struct vsm_chunk *vsm_iter0(const struct VSM_data *vd);
+struct vsm_chunk *vsm_iter0(struct VSM_data *vd);
 void vsm_itern(const struct VSM_data *vd, struct vsm_chunk **pp);
 
 #define VSM_FOREACH(var, vd) \
@@ -169,7 +174,7 @@
 	 * args and returns as VSM_Open()
 	 */
 
-struct vsc_main *VSC_Main(const struct VSM_data *vd);
+struct vsc_main *VSC_Main(struct VSM_data *vd);
 	/*
 	 * return Main stats structure
 	 */
@@ -186,7 +191,7 @@
 
 typedef int vsc_iter_f(void *priv, const struct vsc_point *const pt);
 
-int VSC_Iter(const struct VSM_data *vd, vsc_iter_f *func, void *priv);
+int VSC_Iter(struct VSM_data *vd, vsc_iter_f *func, void *priv);
 	/*
 	 * Iterate over all statistics counters, calling "func" for
 	 * each counter not suppressed by any "-f" arguments.

Modified: trunk/varnish-cache/lib/libvarnishapi/vsc.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsc.c	2010-06-16 10:39:33 UTC (rev 4961)
+++ trunk/varnish-cache/lib/libvarnishapi/vsc.c	2010-06-16 10:40:00 UTC (rev 4962)
@@ -223,7 +223,7 @@
 /*--------------------------------------------------------------------*/
 
 struct vsc_main *
-VSC_Main(const struct VSM_data *vd)
+VSC_Main(struct VSM_data *vd)
 {
 	struct vsm_chunk *sha;
 
@@ -340,7 +340,7 @@
 }
 
 int
-VSC_Iter(const struct VSM_data *vd, vsc_iter_f *func, void *priv)
+VSC_Iter(struct VSM_data *vd, vsc_iter_f *func, void *priv)
 {
 	struct vsc *vsc;
 	struct vsm_chunk *sha;

Modified: trunk/varnish-cache/lib/libvarnishapi/vsm.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsm.c	2010-06-16 10:39:33 UTC (rev 4961)
+++ trunk/varnish-cache/lib/libvarnishapi/vsm.c	2010-06-16 10:40:00 UTC (rev 4962)
@@ -267,7 +267,7 @@
 /*--------------------------------------------------------------------*/
 
 struct vsm_chunk *
-vsm_find_alloc(const struct VSM_data *vd, const char *class, const char *type, const char *ident)
+vsm_find_alloc(struct VSM_data *vd, const char *class, const char *type, const char *ident)
 {
 	struct vsm_chunk *sha;
 
@@ -289,7 +289,7 @@
 /*--------------------------------------------------------------------*/
 
 void *
-VSM_Find_Chunk(const struct VSM_data *vd, const char *class, const char *type,
+VSM_Find_Chunk(struct VSM_data *vd, const char *class, const char *type,
     const char *ident, unsigned *lenp)
 {
 	struct vsm_chunk *sha;
@@ -306,12 +306,15 @@
 /*--------------------------------------------------------------------*/
 
 struct vsm_chunk *
-vsm_iter0(const struct VSM_data *vd)
+vsm_iter0(struct VSM_data *vd)
 {
 
 	CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
-	if (vd->alloc_seq != vd->vsm_head->alloc_seq)
-		return(NULL);
+	vd->alloc_seq = vd->vsm_head->alloc_seq;
+	while (vd->alloc_seq == 0) {
+		usleep(50000);
+		vd->alloc_seq = vd->vsm_head->alloc_seq;
+	}
 	CHECK_OBJ_NOTNULL(&vd->vsm_head->head, VSM_CHUNK_MAGIC);
 	return (&vd->vsm_head->head);
 }
@@ -333,3 +336,12 @@
 	}
 	CHECK_OBJ_NOTNULL(*pp, VSM_CHUNK_MAGIC);
 }
+
+/*--------------------------------------------------------------------*/
+unsigned
+VSM_Seq(struct VSM_data *vd)
+{
+
+	CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
+	return (vd->vsm_head->alloc_seq);
+}

Modified: trunk/varnish-cache/lib/libvarnishapi/vsm_api.h
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsm_api.h	2010-06-16 10:39:33 UTC (rev 4961)
+++ trunk/varnish-cache/lib/libvarnishapi/vsm_api.h	2010-06-16 10:40:00 UTC (rev 4962)
@@ -59,7 +59,7 @@
 	struct vsl		*vsl;
 };
 
-struct vsm_chunk *vsm_find_alloc(const struct VSM_data *vd, const char *class,
+struct vsm_chunk *vsm_find_alloc(struct VSM_data *vd, const char *class,
     const char *type, const char *ident);
 
 void vsc_delete(struct VSM_data *vd);




More information about the varnish-commit mailing list