Commit e60c07ce authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Some VSC functions added

Add a VSC_Mgt() function to get direct access to the management counters

Add VSC_MgtValid(), VSC_MainValid(), VSC_IterValid() functions that
call VSM_StillValid on the fantom used to produce them.

Use the iter fantom when making the pointer lists, so VSM_IterValid()
returns the right result.
parent 12cbc690
......@@ -59,6 +59,12 @@ int VSC_Arg(struct VSM_data *vd, int arg, const char *opt);
* 1 Handled.
*/
struct VSC_C_mgt *VSC_Mgt(struct VSM_data *vd);
/*
* return Management stats structure
* returns NULL until management process has finished initialization.
*/
struct VSC_C_main *VSC_Main(struct VSM_data *vd);
/*
* return Main stats structure
......@@ -113,6 +119,37 @@ int VSC_Iter(struct VSM_data *vd, VSC_iter_f *func, void *priv);
* 0: Done
*/
int VSC_MgtValid(struct VSM_data *vd);
/*
* Call VSM_StillValid on the fantom used to find the management
* counters
*
* Returns:
* 0: fantom is not valid any more
* 1: fantom is still the same.
* 2: a fantom with same dimensions exist.
*/
int VSC_MainValid(struct VSM_data *vd);
/*
* Call VSM_StillValid on the fantom used to find the main counters.
*
* Returns:
* 0: fantom is not valid any more
* 1: fantom is still the same.
* 2: a fantom with same dimensions exist.
*/
int VSC_IterValid(struct VSM_data *vd);
/*
* Call VSM_StillValid on the fantom used to produce the last
* VSC_Iter results.
*
* Returns:
* 0: fantom is not valid any more
* 1: fantom is still the same.
*/
/**********************************************************************
* Precompiled VSC_type_desc's and VSC_desc's for all know VSCs.
*/
......
......@@ -90,5 +90,9 @@ LIBVARNISHAPI_1.3 {
# Functions:
VSM_Abandoned;
VSM_ResetError;
VSC_Mgt;
VSC_MgtValid;
VSC_MainValid;
VSC_IterValid;
# Variables:
} LIBVARNISHAPI_1.0;
......@@ -92,6 +92,7 @@ struct vsc {
VTAILQ_HEAD(, vsc_vf) vf_list;
VTAILQ_HEAD(, vsc_pt) pt_list;
VTAILQ_HEAD(, vsc_sf) sf_list;
struct VSM_fantom mgt_fantom;
struct VSM_fantom main_fantom;
struct VSM_fantom iter_fantom;
};
......@@ -261,6 +262,19 @@ VSC_Arg(struct VSM_data *vd, int arg, const char *opt)
/*--------------------------------------------------------------------*/
struct VSC_C_mgt *
VSC_Mgt(struct VSM_data *vd)
{
struct vsc *vsc = vsc_setup(vd);
if (!VSM_StillValid(vd, &vsc->mgt_fantom) &&
!VSM_Get(vd, &vsc->mgt_fantom, VSC_CLASS, VSC_type_mgt, ""))
return (NULL);
return ((void*)vsc->mgt_fantom.b);
}
/*--------------------------------------------------------------------*/
struct VSC_C_main *
VSC_Main(struct VSM_data *vd)
{
......@@ -276,7 +290,7 @@ VSC_Main(struct VSM_data *vd)
*/
static void
vsc_add_vf(struct vsc *vsc, struct VSM_fantom *fantom,
vsc_add_vf(struct vsc *vsc, const struct VSM_fantom *fantom,
const struct VSC_type_desc *desc, int order)
{
struct vsc_vf *vf, *vf2;
......@@ -346,18 +360,17 @@ static void
vsc_build_vf_list(struct VSM_data *vd)
{
struct vsc *vsc = vsc_setup(vd);
struct VSM_fantom fantom;
vsc_delete_pt_list(vsc);
vsc_delete_vf_list(vsc);
VSM_FOREACH(&fantom, vd) {
if (strcmp(fantom.class, VSC_CLASS))
VSM_FOREACH(&vsc->iter_fantom, vd) {
if (strcmp(vsc->iter_fantom.class, VSC_CLASS))
continue;
#define VSC_TYPE_F(n,t,l,e,d) \
if (!strcmp(fantom.type, t)) \
vsc_add_vf(vsc, &fantom, &VSC_type_desc_##n, \
VSC_type_order_##n);
if (!strcmp(vsc->iter_fantom.type, t)) \
vsc_add_vf(vsc, &vsc->iter_fantom, \
&VSC_type_desc_##n, VSC_type_order_##n);
#include "tbl/vsc_types.h"
#undef VSC_TYPE_F
}
......@@ -465,6 +478,47 @@ VSC_Iter(struct VSM_data *vd, VSC_iter_f *func, void *priv)
return (0);
}
/*--------------------------------------------------------------------
*/
int
VSC_MgtValid(struct VSM_data *vd)
{
struct vsc *vsc = vsc_setup(vd);
fprintf(stderr, "VSC_MgtValid called priv=%ju\n",
vsc->mgt_fantom.priv);
return (VSM_StillValid(vd, &vsc->mgt_fantom));
}
int
VSC_MainValid(struct VSM_data *vd)
{
struct vsc *vsc = vsc_setup(vd);
fprintf(stderr, "VSC_MainValid called priv=%ju\n",
vsc->main_fantom.priv);
return (VSM_StillValid(vd, &vsc->main_fantom));
}
int
VSC_IterValid(struct VSM_data *vd)
{
struct vsc *vsc = vsc_setup(vd);
int v;
fprintf(stderr, "VSC_IterValid called priv=%ju\n",
vsc->iter_fantom.priv);
v = VSM_StillValid(vd, &vsc->iter_fantom);
if (v == 2) {
/* There's been changes, reiteration needed. Clear fantom
so subsequent calls will also fail */
memset(&vsc->iter_fantom, 0, sizeof vsc->iter_fantom);
v = 0;
}
fprintf(stderr, "VSC_IterValid returns %d priv=%ju\n", v,
vsc->iter_fantom.priv);
return (v);
}
/*--------------------------------------------------------------------
* Build the static type and point descriptions
*/
......
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