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
48cbc79b
Commit
48cbc79b
authored
Dec 21, 2017
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put the VSC prefix data in a struct.
...Now that we will need more than one integer.
parent
29872fb8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
21 deletions
+72
-21
common_vsc.c
bin/varnishd/common/common_vsc.c
+13
-6
Makefile.am
include/Makefile.am
+1
-0
vsc_priv.h
include/vsc_priv.h
+44
-0
vsc.c
lib/libvarnishapi/vsc.c
+12
-13
vsctool.py
lib/libvcc/vsctool.py
+2
-2
No files found.
bin/varnishd/common/common_vsc.c
View file @
48cbc79b
...
...
@@ -40,8 +40,8 @@
#include "miniobj.h"
#include "vas.h"
#include "vend.h"
#include "vmb.h"
#include "vsc_priv.h"
#include "vsmw.h"
#include "vqueue.h"
...
...
@@ -56,6 +56,7 @@ struct vsc_segs {
const
char
*
nm
;
VTAILQ_ENTRY
(
vsc_segs
)
list
;
void
*
seg
;
struct
vsc_head
*
head
;
void
*
ptr
;
};
...
...
@@ -72,6 +73,7 @@ VRT_VSC_Alloc(const char *nm, size_t sd, const unsigned char *jp,
char
*
p
;
struct
vsc_segs
*
vsg
;
char
buf
[
1024
];
uint64_t
co
,
jo
;
if
(
vsc_lock
!=
NULL
)
vsc_lock
();
...
...
@@ -81,22 +83,27 @@ VRT_VSC_Alloc(const char *nm, size_t sd, const unsigned char *jp,
else
bprintf
(
buf
,
"%s.%s"
,
nm
,
fmt
);
co
=
PRNDUP
(
sizeof
(
struct
vsc_head
));
jo
=
co
+
PRNDUP
(
sd
);
AN
(
heritage
.
proc_vsmw
);
p
=
VSMW_Allocv
(
heritage
.
proc_vsmw
,
"Stat"
,
8
+
sd
+
sj
,
buf
,
va
);
p
=
VSMW_Allocv
(
heritage
.
proc_vsmw
,
VSC_CLASS
,
jo
+
PRNDUP
(
sj
),
buf
,
va
);
AN
(
p
);
memcpy
(
p
+
8
+
sd
,
jp
,
sj
);
ALLOC_OBJ
(
vsg
,
VSC_SEGS_MAGIC
);
AN
(
vsg
);
vsg
->
seg
=
p
;
vsg
->
ptr
=
p
+
8
;
vsg
->
head
=
(
void
*
)
p
;
vsg
->
head
->
ctr_offset
=
co
;
vsg
->
ptr
=
p
+
co
;
VTAILQ_INSERT_TAIL
(
&
vsc_seglist
,
vsg
,
list
);
memcpy
(
p
+
jo
,
jp
,
sj
);
VWMB
();
v
be64enc
(
p
,
sd
)
;
v
sg
->
head
->
json_offset
=
jo
;
vsg
->
nm
=
nm
;
if
(
vsc_unlock
!=
NULL
)
vsc_unlock
();
return
(
p
+
8
);
return
(
vsg
->
ptr
);
}
void
...
...
include/Makefile.am
View file @
48cbc79b
...
...
@@ -90,6 +90,7 @@ nobase_noinst_HEADERS = \
vmb.h
\
vnum.h
\
vpf.h
\
vsc_priv.h
\
vsl_priv.h
\
vsmw.h
\
vsm_priv.h
\
...
...
include/vsc_priv.h
0 → 100644
View file @
48cbc79b
/*-
* Copyright (c) 2017 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
* Author: Martin Blix Grydeland <martin@varnish-software.com>
*
* 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.
*
* Define the layout of the statistics VSM segments
*
* NB: THIS IS NOT A PUBLIC API TO VARNISH!
*/
#ifdef VSC_PRIV_H_INCLUDED
# error "vsc_priv.h included more than once"
#endif
#define VSC_PRIV_H_INCLUDED
#define VSC_CLASS "Stat"
struct
vsc_head
{
volatile
uint64_t
json_offset
;
uint64_t
ctr_offset
;
};
lib/libvarnishapi/vsc.c
View file @
48cbc79b
...
...
@@ -45,7 +45,7 @@
#include "vqueue.h"
#include "vjsn.h"
#include "vsb.h"
#include "v
end
.h"
#include "v
sc_priv
.h"
#include "vmb.h"
#include "vapi/vsc.h"
...
...
@@ -70,6 +70,7 @@ struct vsc_seg {
VTAILQ_ENTRY
(
vsc_seg
)
list
;
struct
vsm_fantom
fantom
[
1
];
struct
vjsn
*
vj
;
struct
vsc_head
*
head
;
unsigned
npoints
;
struct
vsc_pt
*
points
;
};
...
...
@@ -204,7 +205,7 @@ vsc_clean_point(struct vsc_pt *point)
}
static
int
vsc_fill_point
(
const
struct
vsc
*
vsc
,
const
struct
vsm_fantom
*
fantom
,
vsc_fill_point
(
const
struct
vsc
*
vsc
,
struct
vsc_seg
*
seg
,
const
struct
vjsn_val
*
vv
,
struct
vsb
*
vsb
,
struct
vsc_pt
*
point
)
{
struct
vjsn_val
*
vt
;
...
...
@@ -217,7 +218,7 @@ vsc_fill_point(const struct vsc *vsc, const struct vsm_fantom *fantom,
assert
(
vt
->
type
==
VJSN_STRING
);
VSB_clear
(
vsb
);
VSB_printf
(
vsb
,
"%s.%s"
,
fantom
->
ident
,
vt
->
value
);
VSB_printf
(
vsb
,
"%s.%s"
,
seg
->
fantom
->
ident
,
vt
->
value
);
AZ
(
VSB_finish
(
vsb
));
if
(
vsc_filter
(
vsc
,
VSB_data
(
vsb
)))
...
...
@@ -285,7 +286,8 @@ vsc_fill_point(const struct vsc *vsc, const struct vsm_fantom *fantom,
AN
(
vt
);
point
->
point
.
ptr
=
(
volatile
void
*
)
((
volatile
char
*
)
fantom
->
b
+
atoi
(
vt
->
value
));
((
volatile
char
*
)
seg
->
fantom
->
b
+
seg
->
head
->
ctr_offset
+
atoi
(
vt
->
value
));
return
(
1
);
}
...
...
@@ -314,7 +316,6 @@ static struct vsc_seg *
vsc_add_seg
(
const
struct
vsc
*
vsc
,
struct
vsm
*
vsm
,
const
struct
vsm_fantom
*
fp
)
{
struct
vsc_seg
*
sp
;
uint64_t
u
;
const
char
*
p
;
const
char
*
e
;
struct
vjsn_val
*
vv
,
*
vve
;
...
...
@@ -335,16 +336,14 @@ vsc_add_seg(const struct vsc *vsc, struct vsm *vsm, const struct vsm_fantom *fp)
FREE_OBJ
(
sp
);
return
(
NULL
);
}
// AZ(VSM_Map(vsm, sp->fantom));
u
=
vbe64dec
(
sp
->
fantom
->
b
)
;
if
(
u
==
0
)
{
sp
->
head
=
sp
->
fantom
->
b
;
if
(
sp
->
head
->
json_offset
==
0
)
{
VRMB
();
usleep
(
100000
);
u
=
vbe64dec
(
sp
->
fantom
->
b
);
}
assert
(
u
>
0
);
p
=
(
char
*
)
sp
->
fantom
->
b
+
8
+
u
;
assert
(
sp
->
head
->
json_offset
>
0
);
p
=
(
char
*
)
sp
->
fantom
->
b
+
sp
->
head
->
json_offset
;
assert
(
p
<
(
char
*
)
sp
->
fantom
->
e
);
sp
->
vj
=
vjsn_parse
(
p
,
&
e
);
XXXAZ
(
e
);
...
...
@@ -359,7 +358,7 @@ vsc_add_seg(const struct vsc *vsc, struct vsm *vsm, const struct vsm_fantom *fp)
AN
(
vve
);
pp
=
sp
->
points
;
VTAILQ_FOREACH
(
vv
,
&
vve
->
children
,
list
)
{
if
(
vsc_fill_point
(
vsc
,
sp
->
fantom
,
vv
,
vsb
,
pp
)
&&
if
(
vsc_fill_point
(
vsc
,
sp
,
vv
,
vsb
,
pp
)
&&
vsc
->
fnew
!=
NULL
)
pp
->
point
.
priv
=
vsc
->
fnew
(
vsc
->
priv
,
&
pp
->
point
);
pp
++
;
...
...
@@ -399,7 +398,7 @@ VSC_Iter(struct vsc *vsc, struct vsm *vsm, VSC_iter_f *fiter, void *priv)
AN
(
vsm
);
sp
=
VTAILQ_FIRST
(
&
vsc
->
segs
);
VSM_FOREACH
(
&
ifantom
,
vsm
)
{
if
(
strcmp
(
ifantom
.
class
,
"Stat"
))
if
(
strcmp
(
ifantom
.
class
,
VSC_CLASS
))
continue
;
while
(
sp
!=
NULL
&&
(
strcmp
(
ifantom
.
ident
,
sp
->
fantom
->
ident
)
||
...
...
lib/libvcc/vsctool.py
View file @
48cbc79b
...
...
@@ -79,7 +79,7 @@ class vscset(object):
self
.
mbrs
=
[]
self
.
head
=
m
self
.
completed
=
False
self
.
off
=
8
self
.
off
=
0
def
addmbr
(
self
,
m
):
assert
not
self
.
completed
...
...
@@ -177,7 +177,7 @@ class vscset(object):
for
i
in
self
.
mbrs
:
fo
.
write
(
"PARANOIA("
+
i
.
arg
)
fo
.
write
(
",
%
d);
\n
"
%
(
i
.
param
[
"index"
]
-
8
))
fo
.
write
(
",
%
d);
\n
"
%
(
i
.
param
[
"index"
]))
fo
.
write
(
"#undef PARANOIA
\n
"
)
...
...
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