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
f066db70
Commit
f066db70
authored
May 23, 2017
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Take the 'zero' element out of the VSC structures again, and syntax
check the JSON payload.
parent
5cc0e270
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
77 additions
and
25 deletions
+77
-25
cache_backend_cfg.c
bin/varnishd/cache/cache_backend_cfg.c
+2
-4
cache_mempool.c
bin/varnishd/cache/cache_mempool.c
+1
-1
cache_shmlog.c
bin/varnishd/cache/cache_shmlog.c
+34
-5
mgt_main.c
bin/varnishd/mgt/mgt_main.c
+1
-0
storage_malloc.c
bin/varnishd/storage/storage_malloc.c
+0
-1
vsc_int.h
include/vapi/vsc_int.h
+1
-1
vsc.c
lib/libvarnishapi/vsc.c
+35
-7
vsctool.py
lib/libvcc/vsctool.py
+3
-6
No files found.
bin/varnishd/cache/cache_backend_cfg.c
View file @
f066db70
...
...
@@ -186,10 +186,8 @@ VBE_Event(struct backend *be, enum vcl_event_e ev)
if
(
be
->
probe
!=
NULL
&&
ev
==
VCL_EVENT_COLD
)
VBP_Control
(
be
,
0
);
if
(
ev
==
VCL_EVENT_COLD
)
{
VSM_Free
(
be
->
vsc
);
be
->
vsc
=
NULL
;
}
if
(
ev
==
VCL_EVENT_COLD
)
VSC_vbe_Destroy
(
&
be
->
vsc
);
}
void
...
...
bin/varnishd/cache/cache_mempool.c
View file @
f066db70
...
...
@@ -160,7 +160,7 @@ mpl_guard(void *priv)
FREE_OBJ
(
mi
);
mi
=
NULL
;
}
VS
M_Free
(
mpl
->
vsc
);
VS
C_mempool_Destroy
(
&
mpl
->
vsc
);
Lck_Unlock
(
&
mpl
->
mtx
);
Lck_Delete
(
&
mpl
->
mtx
);
FREE_OBJ
(
mpl
);
...
...
bin/varnishd/cache/cache_shmlog.c
View file @
f066db70
...
...
@@ -472,6 +472,18 @@ VSL_End(struct vsl_log *vsl)
/*--------------------------------------------------------------------*/
struct
vsc_segs
{
unsigned
magic
;
#define VSC_SEGS_MAGIC 0x9b355991
VTAILQ_ENTRY
(
vsc_segs
)
list
;
void
*
seg
;
void
*
ptr
;
};
static
VTAILQ_HEAD
(,
vsc_segs
)
vsc_seglist
=
VTAILQ_HEAD_INITIALIZER
(
vsc_seglist
);
void
*
VSC_Alloc
(
const
char
*
nm
,
size_t
sd
,
size_t
sj
,
const
unsigned
char
*
zj
,
size_t
szj
,
...
...
@@ -479,33 +491,50 @@ VSC_Alloc(const char *nm, size_t sd,
{
char
*
p
;
z_stream
vz
;
struct
vsc_segs
*
vsg
;
(
void
)
nm
;
(
void
)
fmt
;
(
void
)
va
;
p
=
VSM_Alloc
(
sd
+
sj
,
VSC_CLASS
,
nm
,
fmt
);
p
=
VSM_Alloc
(
8
+
sd
+
sj
,
VSC_CLASS
,
nm
,
fmt
);
AN
(
p
);
memset
(
p
,
0
,
sd
);
vbe64enc
(
p
,
sd
);
// fills .zero
vbe64enc
(
p
,
sd
);
memset
(
&
vz
,
0
,
sizeof
vz
);
assert
(
Z_OK
==
inflateInit2
(
&
vz
,
31
));
vz
.
next_in
=
TRUST_ME
(
zj
);
vz
.
avail_in
=
szj
;
vz
.
next_out
=
(
void
*
)(
p
+
sd
);
vz
.
next_out
=
(
void
*
)(
p
+
8
+
sd
);
vz
.
avail_out
=
sj
;
assert
(
Z_STREAM_END
==
inflate
(
&
vz
,
Z_FINISH
));
assert
(
Z_OK
==
inflateEnd
(
&
vz
));
return
(
p
);
ALLOC_OBJ
(
vsg
,
VSC_SEGS_MAGIC
);
vsg
->
seg
=
p
;
vsg
->
ptr
=
p
+
8
;
VTAILQ_INSERT_TAIL
(
&
vsc_seglist
,
vsg
,
list
);
return
(
p
+
8
);
}
void
VSC_Destroy
(
const
char
*
nm
,
void
*
p
)
{
struct
vsc_segs
*
vsg
;
(
void
)
nm
;
(
void
)
p
;
VTAILQ_FOREACH
(
vsg
,
&
vsc_seglist
,
list
)
{
if
(
vsg
->
ptr
!=
p
)
continue
;
VSM_Free
(
vsg
->
seg
);
VTAILQ_REMOVE
(
&
vsc_seglist
,
vsg
,
list
);
FREE_OBJ
(
vsg
);
return
;
}
WRONG
(
"Freeing unknown VSC"
);
}
/*--------------------------------------------------------------------*/
...
...
bin/varnishd/mgt/mgt_main.c
View file @
f066db70
...
...
@@ -47,6 +47,7 @@
#include "hash/hash_slinger.h"
#include "vav.h"
#include "vcli_serve.h"
#include "vend.h"
#include "vev.h"
#include "vfil.h"
#include "vin.h"
...
...
bin/varnishd/storage/storage_malloc.c
View file @
f066db70
...
...
@@ -214,7 +214,6 @@ sma_open(struct stevedore *st)
CAST_OBJ_NOTNULL
(
sma_sc
,
st
->
priv
,
SMA_SC_MAGIC
);
Lck_New
(
&
sma_sc
->
sma_mtx
,
lck_sma
);
sma_sc
->
stats
=
VSC_sma_New
(
st
->
ident
);
memset
(
sma_sc
->
stats
,
0
,
sizeof
*
sma_sc
->
stats
);
if
(
sma_sc
->
sma_max
!=
SIZE_MAX
)
sma_sc
->
stats
->
g_space
=
sma_sc
->
sma_max
;
}
...
...
include/vapi/vsc_int.h
View file @
f066db70
...
...
@@ -43,7 +43,7 @@ enum VSC_level_e {
#include "tbl/vsc_types.h"
/* Define the vsc type structs */
#define VSC_DO(u,l,t,h) struct VSC_C_##l {
uint64_t zero;
#define VSC_DO(u,l,t,h) struct VSC_C_##l {
#define VSC_F(n,t,l,s,f,v,d,e) t n;
#define VSC_DONE(u,l,t) };
#include "tbl/vsc_all.h"
lib/libvarnishapi/vsc.c
View file @
f066db70
...
...
@@ -34,6 +34,7 @@
#include <fnmatch.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -41,7 +42,9 @@
#include "vas.h"
#include "miniobj.h"
#include "vqueue.h"
#include "vjsn.h"
#include "vsb.h"
#include "vend.h"
#include "vapi/vsc.h"
#include "vapi/vsm.h"
...
...
@@ -246,7 +249,7 @@ VSC_Get(const struct VSM_data *vd, struct VSM_fantom *fantom, const char *type,
if
(
VSM_invalid
==
VSM_StillValid
(
vd
,
fantom
)
&&
!
VSM_Get
(
vd
,
fantom
,
VSC_CLASS
,
type
,
ident
))
return
(
NULL
);
return
((
void
*
)
fantom
->
b
);
return
((
void
*
)
((
char
*
)
fantom
->
b
+
8
)
);
}
/*--------------------------------------------------------------------*/
...
...
@@ -300,7 +303,7 @@ vsc_add_pt(struct vsc *vsc, const volatile void *ptr,
struct VSC_C_##l *st; \
\
CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); \
st =
vf->fantom.b
;
st =
(void*)((char*)vf->fantom.b + 8)
;
#define VSC_F(nn,tt,ll,ss,ff,vv,dd,ee) \
vsc_add_pt(vsc, &st->nn, descs++, vf);
...
...
@@ -313,10 +316,26 @@ vsc_add_pt(struct vsc *vsc, const volatile void *ptr,
/*--------------------------------------------------------------------
*/
static
void
vsc_build_old_vf_list
(
struct
vsc
*
vsc
)
{
#define VSC_TYPE_F(n,t,l,e,d) \
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"
}
#include <stdio.h>
static
void
vsc_build_vf_list
(
struct
VSM_data
*
vd
)
{
uint64_t
u
;
struct
vsc
*
vsc
=
vsc_setup
(
vd
);
struct
vjsn
*
vj
;
const
char
*
p
;
const
char
*
e
;
vsc_delete_pt_list
(
&
vsc
->
pt_list
);
vsc_delete_vf_list
(
&
vsc
->
vf_list
);
...
...
@@ -324,11 +343,20 @@ vsc_build_vf_list(struct VSM_data *vd)
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(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"
u
=
vbe64dec
(
vsc
->
iter_fantom
.
b
);
vsc_build_old_vf_list
(
vsc
);
if
(
u
==
0
)
{
fprintf
(
stderr
,
"%s has no JSON
\n
"
,
vsc
->
iter_fantom
.
type
);
exit
(
2
);
}
p
=
(
char
*
)
vsc
->
iter_fantom
.
b
+
8
+
u
;
vj
=
vjsn_parse
(
p
,
&
e
);
if
(
e
!=
NULL
)
{
fprintf
(
stderr
,
"%s
\n
"
,
p
);
fprintf
(
stderr
,
"JSON ERROR %s
\n
"
,
e
);
}
AZ
(
e
);
//vjsn_dump(vj, stdout);
}
}
...
...
lib/libvcc/vsctool.py
View file @
f066db70
...
...
@@ -89,7 +89,7 @@ class vscset(object):
ed
[
"level"
]
=
i
.
param
[
"level"
]
ed
[
"1line"
]
=
i
.
param
[
"oneliner"
]
.
strip
()
ed
[
"docs"
]
=
i
.
getdoc
()
s
=
json
.
dumps
(
dd
,
separators
=
(
","
,
":"
))
s
=
json
.
dumps
(
dd
,
separators
=
(
","
,
":"
))
+
"
\0
"
fo
.
write
(
"
\n
static const size_t vsc_
%
s_jsonlen =
%
dL;
\n
"
%
(
self
.
name
,
len
(
s
)))
z
=
gzip_str
(
s
)
...
...
@@ -116,14 +116,13 @@ class vscset(object):
fo
=
open
(
fon
,
"w"
)
genhdr
(
fo
,
self
.
name
)
fo
.
write
(
self
.
struct
+
" {
\n
"
)
fo
.
write
(
"
\t
uint64_t
\t
zero;
\n
"
)
for
i
in
self
.
mbrs
:
fo
.
write
(
"
\t
uint64_t
\t
%
s;
\n
"
%
i
.
arg
)
fo
.
write
(
"};
\n
"
)
fo
.
write
(
"
\n
"
);
fo
.
write
(
self
.
struct
+
" *VSC_"
+
self
.
name
+
"_New"
)
fo
.
write
(
"(const char *fmt, ...);
\n
"
);
fo
.
write
(
"void VSC
L
_"
+
self
.
name
+
"_Destroy"
)
fo
.
write
(
"void VSC_"
+
self
.
name
+
"_Destroy"
)
fo
.
write
(
"("
+
self
.
struct
+
"**);
\n
"
)
def
emit_c
(
self
):
...
...
@@ -162,7 +161,7 @@ class vscset(object):
fo
.
write
(
"}
\n
"
)
fo
.
write
(
"
\n
"
)
fo
.
write
(
"void
\n
"
)
fo
.
write
(
"VSC
L
_"
+
self
.
name
+
"_Destroy"
)
fo
.
write
(
"VSC_"
+
self
.
name
+
"_Destroy"
)
fo
.
write
(
"("
+
self
.
struct
+
"**pp)
\n
"
)
fo
.
write
(
"{
\n
"
)
fo
.
write
(
"
\n
"
)
...
...
@@ -285,8 +284,6 @@ class vsc_file(object):
for
i
in
self
.
c
:
i
.
vscset
(
self
.
vscset
)
print
(
self
.
vscset
)
def
emit_h
(
self
):
for
i
in
self
.
vscset
:
i
.
emit_h
()
...
...
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