Commit 9d5dc52c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make varnishstat discover dynamic allocations in curses mode.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4962 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 9877c0d5
......@@ -74,7 +74,7 @@ do_xml_cb(void *priv, const struct vsc_point * const pt)
}
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 @@ do_once_cb(void *priv, const struct vsc_point * const pt)
}
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 @@ do_list_cb(void *priv, const struct vsc_point * const pt)
}
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");
......
......@@ -100,7 +100,7 @@ do_curses_cb(void *priv, const struct vsc_point * const sp)
}
static void
prep_pts(const struct VSM_data *vd)
prep_pts(struct VSM_data *vd)
{
struct pt *pt, *pt2;
......@@ -135,6 +135,7 @@ do_curses(struct VSM_data *vd, const struct vsc_main *VSL_stats,
int ch, line;
struct pt *pt;
double act, lact;
unsigned seq;
(void)initscr();
AC(raw());
......@@ -147,6 +148,7 @@ do_curses(struct VSM_data *vd, const struct vsc_main *VSL_stats,
/*
* Initialization goes in outher loop
*/
seq = VSM_Seq(vd);
prep_pts(vd);
AC(erase());
AC(refresh());
......@@ -159,6 +161,8 @@ do_curses(struct VSM_data *vd, const struct vsc_main *VSL_stats,
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.
......
......@@ -110,12 +110,17 @@ int VSM_ReOpen(struct VSM_data *vd, int diag);
* -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 @@ void VSM_Close(struct VSM_data *vd);
* 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 @@ int VSC_Open(struct VSM_data *vd, int diag);
* 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 @@ struct vsc_point {
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.
......
......@@ -223,7 +223,7 @@ VSC_Open(struct VSM_data *vd, int diag)
/*--------------------------------------------------------------------*/
struct vsc_main *
VSC_Main(const struct VSM_data *vd)
VSC_Main(struct VSM_data *vd)
{
struct vsm_chunk *sha;
......@@ -340,7 +340,7 @@ iter_sma(const struct vsc *vsc, struct vsm_chunk *sha, vsc_iter_f *func,
}
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;
......
......@@ -267,7 +267,7 @@ VSM_Head(const struct VSM_data *vd)
/*--------------------------------------------------------------------*/
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 @@ vsm_find_alloc(const struct VSM_data *vd, const char *class, const char *type, c
/*--------------------------------------------------------------------*/
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 @@ VSM_Find_Chunk(const struct VSM_data *vd, const char *class, const char *type,
/*--------------------------------------------------------------------*/
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 @@ vsm_itern(const struct VSM_data *vd, struct vsm_chunk **pp)
}
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);
}
......@@ -59,7 +59,7 @@ struct VSM_data {
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment