Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
344b83c7
Commit
344b83c7
authored
Sep 07, 2017
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make VSC not own the VSM it operates on.
parent
1f8d76c1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
38 deletions
+37
-38
varnishstat.c
bin/varnishstat/varnishstat.c
+18
-15
varnishstat_curses.c
bin/varnishstat/varnishstat_curses.c
+3
-3
vtc_varnish.c
bin/varnishtest/vtc_varnish.c
+5
-5
vsc.h
include/vapi/vsc.h
+3
-2
vsc.c
lib/libvarnishapi/vsc.c
+8
-13
No files found.
bin/varnishstat/varnishstat.c
View file @
344b83c7
...
...
@@ -74,7 +74,7 @@ do_xml_cb(void *priv, const struct VSC_point * const pt)
}
static
void
do_xml
(
struct
vsc
*
vsc
)
do_xml
(
struct
vs
m
*
vsm
,
struct
vs
c
*
vsc
)
{
char
time_stamp
[
20
];
time_t
now
;
...
...
@@ -83,7 +83,7 @@ do_xml(struct vsc *vsc)
now
=
time
(
NULL
);
(
void
)
strftime
(
time_stamp
,
20
,
"%Y-%m-%dT%H:%M:%S"
,
localtime
(
&
now
));
printf
(
"<varnishstat timestamp=
\"
%s
\"
>
\n
"
,
time_stamp
);
(
void
)
VSC_Iter
(
vsc
,
NULL
,
do_xml_cb
,
NULL
);
(
void
)
VSC_Iter
(
vsc
,
vsm
,
NULL
,
do_xml_cb
,
NULL
);
printf
(
"</varnishstat>
\n
"
);
}
...
...
@@ -124,7 +124,7 @@ do_json_cb(void *priv, const struct VSC_point * const pt)
}
static
void
do_json
(
struct
vsc
*
vsc
)
do_json
(
struct
vs
m
*
vsm
,
struct
vs
c
*
vsc
)
{
char
time_stamp
[
20
];
time_t
now
;
...
...
@@ -137,7 +137,7 @@ do_json(struct vsc *vsc)
(
void
)
strftime
(
time_stamp
,
20
,
"%Y-%m-%dT%H:%M:%S"
,
localtime
(
&
now
));
printf
(
"
\"
timestamp
\"
:
\"
%s
\"
,
\n
"
,
time_stamp
);
(
void
)
VSC_Iter
(
vsc
,
NULL
,
do_json_cb
,
&
jp
);
(
void
)
VSC_Iter
(
vsc
,
vsm
,
NULL
,
do_json_cb
,
&
jp
);
printf
(
"
\n
}
\n
"
);
}
...
...
@@ -194,15 +194,15 @@ do_once_cb(void *priv, const struct VSC_point * const pt)
}
static
void
do_once
(
struct
vsc
*
vsc
)
do_once
(
struct
vs
m
*
vsm
,
struct
vs
c
*
vsc
)
{
struct
once_priv
op
;
memset
(
&
op
,
0
,
sizeof
op
);
op
.
pad
=
18
;
(
void
)
VSC_Iter
(
vsc
,
NULL
,
do_once_cb_first
,
&
op
);
(
void
)
VSC_Iter
(
vsc
,
NULL
,
do_once_cb
,
&
op
);
(
void
)
VSC_Iter
(
vsc
,
vsm
,
NULL
,
do_once_cb_first
,
&
op
);
(
void
)
VSC_Iter
(
vsc
,
vsm
,
NULL
,
do_once_cb
,
&
op
);
}
/*--------------------------------------------------------------------*/
...
...
@@ -226,13 +226,13 @@ do_list_cb(void *priv, const struct VSC_point * const pt)
}
static
void
list_fields
(
struct
vsc
*
vsc
)
list_fields
(
struct
vs
m
*
vsm
,
struct
vs
c
*
vsc
)
{
printf
(
"Varnishstat -f option fields:
\n
"
);
printf
(
"Field name Description
\n
"
);
printf
(
"---------- -----------
\n
"
);
(
void
)
VSC_Iter
(
vsc
,
NULL
,
do_list_cb
,
NULL
);
(
void
)
VSC_Iter
(
vsc
,
vsm
,
NULL
,
do_list_cb
,
NULL
);
}
/*--------------------------------------------------------------------*/
...
...
@@ -261,7 +261,7 @@ main(int argc, char * const *argv)
VUT_Init
(
progname
,
argc
,
argv
,
&
vopt_spec
);
vd
=
VSM_New
();
AN
(
vd
);
vsc
=
VSC_New
(
vd
);
vsc
=
VSC_New
();
AN
(
vsc
);
while
((
opt
=
getopt
(
argc
,
argv
,
vopt_spec
.
vopt_optstring
))
!=
-
1
)
{
...
...
@@ -284,8 +284,11 @@ main(int argc, char * const *argv)
case
'j'
:
json
=
1
;
break
;
case
'f'
:
AN
(
VSC_Arg
(
vsc
,
opt
,
optarg
));
break
;
default:
i
=
VS
C_Arg
(
vsc
,
opt
,
optarg
);
i
=
VS
M_Arg
(
vd
,
opt
,
optarg
);
if
(
i
<
0
)
VUT_Error
(
1
,
"%s"
,
VSM_Error
(
vd
));
if
(
!
i
)
...
...
@@ -305,13 +308,13 @@ main(int argc, char * const *argv)
if
(
curses
)
do_curses
(
vd
,
vsc
,
1
.
0
);
else
if
(
xml
)
do_xml
(
vsc
);
do_xml
(
v
d
,
v
sc
);
else
if
(
json
)
do_json
(
vsc
);
do_json
(
v
d
,
v
sc
);
else
if
(
once
)
do_once
(
vsc
);
do_once
(
v
d
,
v
sc
);
else
if
(
f_list
)
list_fields
(
vsc
);
list_fields
(
v
d
,
v
sc
);
else
assert
(
0
);
...
...
bin/varnishstat/varnishstat_curses.c
View file @
344b83c7
...
...
@@ -313,7 +313,7 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt)
}
static
void
build_pt_list
(
struct
vsc
*
vsc
,
struct
vsm_fantom
*
fantom
)
build_pt_list
(
struct
vsc
*
vsc
,
struct
vsm
*
vsm
,
struct
vsm
_fantom
*
fantom
)
{
struct
pt_priv
pt_priv
;
int
i
;
...
...
@@ -334,7 +334,7 @@ build_pt_list(struct vsc *vsc, struct vsm_fantom *fantom)
main_cache_hit
=
NULL
;
main_cache_miss
=
NULL
;
(
void
)
VSC_Iter
(
vsc
,
fantom
,
build_pt_list_cb
,
&
pt_priv
);
(
void
)
VSC_Iter
(
vsc
,
vsm
,
fantom
,
build_pt_list_cb
,
&
pt_priv
);
delete_pt_list
();
AN
(
VTAILQ_EMPTY
(
&
ptlist
));
AZ
(
n_ptlist
);
...
...
@@ -1073,7 +1073,7 @@ do_curses(struct vsm *vd, struct vsc *vsc, double delay)
(
VSM_Status
(
vd
)
&
(
VSM_MGT_CHANGED
|
VSM_WRK_CHANGED
)))
{
init_hitrate
();
delete_pt_list
();
build_pt_list
(
vsc
,
&
f_iter
);
build_pt_list
(
vsc
,
vd
,
&
f_iter
);
initial
=
0
;
}
...
...
bin/varnishtest/vtc_varnish.c
View file @
344b83c7
...
...
@@ -523,13 +523,13 @@ varnish_launch(struct varnish *v)
v
->
vsm_vsc
=
VSM_New
();
AN
(
v
->
vsm_vsc
);
v
->
vsc
=
VSC_New
(
v
->
vsm_vsc
);
v
->
vsc
=
VSC_New
();
AN
(
v
->
vsc
);
(
void
)
VSC_Arg
(
v
->
vsc
,
'n'
,
v
->
workdir
);
assert
(
VSM_Arg
(
v
->
vsm_vsc
,
'n'
,
v
->
workdir
)
>
0
);
AZ
(
VSM_Attach
(
v
->
vsm_vsc
,
-
1
));
v
->
vsm_vsl
=
VSM_New
();
(
void
)
VSM_Arg
(
v
->
vsm_vsl
,
'n'
,
v
->
workdir
);
assert
(
VSM_Arg
(
v
->
vsm_vsl
,
'n'
,
v
->
workdir
)
>
0
);
AZ
(
VSM_Attach
(
v
->
vsm_vsl
,
-
1
));
AZ
(
pthread_create
(
&
v
->
tp_vsl
,
NULL
,
varnishlog_thread
,
v
));
...
...
@@ -850,7 +850,7 @@ varnish_vsc(const struct varnish *v, const char *arg)
dp
.
arg
=
arg
;
(
void
)
VSM_Status
(
v
->
vsm_vsc
);
(
void
)
VSC_Iter
(
v
->
vsc
,
NULL
,
do_stat_dump_cb
,
&
dp
);
(
void
)
VSC_Iter
(
v
->
vsc
,
v
->
vsm_vsc
,
NULL
,
do_stat_dump_cb
,
&
dp
);
}
/**********************************************************************
...
...
@@ -916,7 +916,7 @@ varnish_expect(const struct varnish *v, char * const *av)
for
(
i
=
0
;
i
<
50
;
i
++
,
(
void
)
usleep
(
100000
))
{
(
void
)
VSM_Status
(
v
->
vsm_vsc
);
good
=
VSC_Iter
(
v
->
vsc
,
NULL
,
do_expect_cb
,
&
sp
);
good
=
VSC_Iter
(
v
->
vsc
,
v
->
vsm_vsc
,
NULL
,
do_expect_cb
,
&
sp
);
if
(
!
good
)
{
good
=
-
2
;
continue
;
...
...
include/vapi/vsc.h
View file @
344b83c7
...
...
@@ -45,7 +45,7 @@ struct vsm_fantom;
* VSC level access functions
*/
struct
vsc
*
VSC_New
(
struct
vsm
*
);
struct
vsc
*
VSC_New
(
void
);
void
VSC_Destroy
(
struct
vsc
**
);
int
VSC_Arg
(
struct
vsc
*
,
char
arg
,
const
char
*
opt
);
...
...
@@ -84,7 +84,8 @@ void VSC_Destroy_Point(struct VSC_point **);
typedef
int
VSC_iter_f
(
void
*
priv
,
const
struct
VSC_point
*
const
pt
);
int
VSC_Iter
(
struct
vsc
*
,
struct
vsm_fantom
*
,
VSC_iter_f
*
func
,
void
*
priv
);
int
VSC_Iter
(
struct
vsc
*
,
struct
vsm
*
,
struct
vsm_fantom
*
,
VSC_iter_f
*
func
,
void
*
priv
);
/*
* Iterate over all statistics counters, calling "func" for
* each counter not suppressed by any "-f" arguments.
...
...
lib/libvarnishapi/vsc.c
View file @
344b83c7
...
...
@@ -63,7 +63,6 @@ struct vsc {
unsigned
magic
;
#define VSC_MAGIC 0x3373554a
struct
vsm
*
vsm
;
struct
vsc_sf_head
sf_list_include
;
struct
vsc_sf_head
sf_list_exclude
;
};
...
...
@@ -116,15 +115,13 @@ VSC_Destroy_Point(struct VSC_point **p)
/*--------------------------------------------------------------------*/
struct
vsc
*
VSC_New
(
struct
vsm
*
vsm
)
VSC_New
(
void
)
{
struct
vsc
*
vsc
;
AN
(
vsm
);
ALLOC_OBJ
(
vsc
,
VSC_MAGIC
);
if
(
vsc
==
NULL
)
return
(
vsc
);
vsc
->
vsm
=
vsm
;
VTAILQ_INIT
(
&
vsc
->
sf_list_include
);
VTAILQ_INIT
(
&
vsc
->
sf_list_exclude
);
return
(
vsc
);
...
...
@@ -196,11 +193,7 @@ VSC_Arg(struct vsc *vsc, char arg, const char *opt)
switch
(
arg
)
{
case
'f'
:
return
(
vsc_f_arg
(
vsc
,
opt
));
case
'n'
:
case
't'
:
return
(
VSM_Arg
(
vsc
->
vsm
,
arg
,
opt
));
default:
return
(
0
);
default:
return
(
0
);
}
}
...
...
@@ -345,7 +338,8 @@ vsc_iter_fantom(const struct vsc *vsc, const struct vsm_fantom *fantom,
*/
int
__match_proto__
()
// We don't want vsc to be const
VSC_Iter
(
struct
vsc
*
vsc
,
struct
vsm_fantom
*
f
,
VSC_iter_f
*
func
,
void
*
priv
)
VSC_Iter
(
struct
vsc
*
vsc
,
struct
vsm
*
vsm
,
struct
vsm_fantom
*
f
,
VSC_iter_f
*
func
,
void
*
priv
)
{
struct
vsm_fantom
ifantom
;
uint64_t
u
;
...
...
@@ -353,12 +347,13 @@ VSC_Iter(struct vsc *vsc, struct vsm_fantom *f, VSC_iter_f *func, void *priv)
struct
vsb
*
vsb
;
CHECK_OBJ_NOTNULL
(
vsc
,
VSC_MAGIC
);
AN
(
vsm
);
vsb
=
VSB_new_auto
();
AN
(
vsb
);
VSM_FOREACH
(
&
ifantom
,
vs
c
->
vs
m
)
{
VSM_FOREACH
(
&
ifantom
,
vsm
)
{
if
(
strcmp
(
ifantom
.
class
,
VSC_CLASS
))
continue
;
AZ
(
VSM_Map
(
vs
c
->
vs
m
,
&
ifantom
));
AZ
(
VSM_Map
(
vsm
,
&
ifantom
));
u
=
vbe64dec
(
ifantom
.
b
);
if
(
u
==
0
)
{
VRMB
();
...
...
@@ -370,7 +365,7 @@ VSC_Iter(struct vsc *vsc, struct vsm_fantom *f, VSC_iter_f *func, void *priv)
if
(
f
!=
NULL
)
{
*
f
=
ifantom
;
}
else
{
AZ
(
VSM_Unmap
(
vs
c
->
vs
m
,
&
ifantom
));
AZ
(
VSM_Unmap
(
vsm
,
&
ifantom
));
}
if
(
i
)
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment