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
9f5044eb
Unverified
Commit
9f5044eb
authored
Oct 26, 2021
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Macros for VCL_STRANDS creation
parent
d10a8b25
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
27 deletions
+29
-27
cache_vrt.c
bin/varnishd/cache/cache_vrt.c
+1
-0
changes.rst
doc/changes.rst
+14
-0
vrt.h
include/vrt.h
+6
-0
vcc_expr.c
lib/libvcc/vcc_expr.c
+4
-7
vmod_debug.c
vmod/vmod_debug.c
+1
-7
vmod_directors_shard.c
vmod/vmod_directors_shard.c
+1
-6
vmod_directors_shard_cfg.c
vmod/vmod_directors_shard_cfg.c
+2
-7
No files found.
bin/varnishd/cache/cache_vrt.c
View file @
9f5044eb
...
...
@@ -54,6 +54,7 @@
#include "common/vsmw.h"
#include "proxy/cache_proxy.h"
// NOT using TOSTRANDS() to create a NULL pointer element despite n == 0
const
struct
strands
*
vrt_null_strands
=
&
(
struct
strands
){
.
n
=
0
,
.
p
=
(
const
char
*
[
1
]){
NULL
}
...
...
doc/changes.rst
View file @
9f5044eb
...
...
@@ -31,6 +31,20 @@ http://varnish-cache.org/docs/trunk/whats-new/index.html and via
individual releases. These documents are updated as part of the
release process.
===============================
Varnish Cache NEXT (2022-03-15)
===============================
* Added macros ``TOSTRAND(s)`` and ``TOSTRANDS(x, ...)`` to create a
``struct strands *`` (intended to be used as a ``VCL_STANDS``) from
a single string ``s`` or ``x`` strings, respectively.
Note that the macros create a local pointer value (on the stack),
which should only be used for local variables and parameters, but
never as a function return value (use ``VRT_AllocStrandsWS()`` for
that or just return a ``VCL_STRING`` result created with
``VRT_StrandsWS()``).
================================
Varnish Cache 7.0.0 (2021-09-15)
================================
...
...
include/vrt.h
View file @
9f5044eb
...
...
@@ -281,6 +281,12 @@ struct strands {
*/
extern
const
struct
strands
*
vrt_null_strands
;
/*
* Macros for VCL_STRANDS creation
*/
#define TOSTRAND(s)(&(struct strands){.n=1,.p=(const char *[1]){s}})
#define TOSTRANDS(x, ...)(&(struct strands){.n=x,.p=(const char *[x]){__VA_ARGS__}})
/***********************************************************************
* VCL_BLOB:
*
...
...
lib/libvcc/vcc_expr.c
View file @
9f5044eb
...
...
@@ -180,9 +180,8 @@ vcc_expr_edit(struct vcc *tl, vcc_type_t fmt, const char *p, struct expr *e1,
VSB_cat
(
e
->
vsb
,
"
\n
VRT_STRANDS_string(ctx,
\v
+
\n
"
);
VSB_printf
(
e
->
vsb
,
"&(struct strands){.n = %d, .p = "
"(const char *[%d]){
\n
%s
\n
}}"
,
e3
->
nstr
,
e3
->
nstr
,
VSB_data
(
e3
->
vsb
));
"TOSTRANDS(%d,%s)"
,
e3
->
nstr
,
VSB_data
(
e3
->
vsb
));
VSB_cat
(
e
->
vsb
,
"
\v
-
\n
)
\n
"
);
}
else
{
...
...
@@ -193,10 +192,8 @@ vcc_expr_edit(struct vcc *tl, vcc_type_t fmt, const char *p, struct expr *e1,
case
't'
:
e3
=
(
*
p
==
'T'
?
e1
:
e2
);
AN
(
e3
);
VSB_printf
(
e
->
vsb
,
"&(struct strands){.n = %d, .p = "
"(const char *[%d]){
\n
%s
\n
}}"
,
e3
->
nstr
,
e3
->
nstr
,
VSB_data
(
e3
->
vsb
));
VSB_printf
(
e
->
vsb
,
"TOSTRANDS(%d,%s)"
,
e3
->
nstr
,
VSB_data
(
e3
->
vsb
));
break
;
case
'1'
:
VSB_cat
(
e
->
vsb
,
VSB_data
(
e1
->
vsb
));
...
...
vmod/vmod_debug.c
View file @
9f5044eb
...
...
@@ -517,15 +517,9 @@ event_warm(VRT_CTX, const struct vmod_priv *priv)
{
struct
priv_vcl
*
priv_vcl
;
char
buf
[
32
];
const
char
*
p
[
2
];
struct
strands
msg
[
1
];
// Using VSLs for coverage
msg
->
n
=
2
;
msg
->
p
=
p
;
p
[
0
]
=
VCL_Name
(
ctx
->
vcl
);
p
[
1
]
=
": VCL_EVENT_WARM"
;
VSLs
(
SLT_Debug
,
0
,
msg
);
VSLs
(
SLT_Debug
,
0
,
TOSTRANDS
(
2
,
VCL_Name
(
ctx
->
vcl
),
": VCL_EVENT_WARM"
));
AN
(
ctx
->
msg
);
if
(
cache_param
->
max_esi_depth
==
42
)
{
...
...
vmod/vmod_directors_shard.c
View file @
9f5044eb
...
...
@@ -373,8 +373,6 @@ static inline uint32_t
shard_get_key
(
VRT_CTX
,
const
struct
vmod_directors_shard_param
*
p
)
{
struct
http
*
http
;
struct
strands
s
[
1
];
const
char
*
sp
[
1
];
VCL_ENUM
by
=
default_by
(
p
->
by
);
if
(
by
==
VENUM
(
KEY
)
||
by
==
VENUM
(
BLOB
))
...
...
@@ -390,10 +388,7 @@ shard_get_key(VRT_CTX, const struct vmod_directors_shard_param *p)
AN
(
ctx
->
http_bereq
);
AN
(
http
=
ctx
->
http_bereq
);
}
sp
[
0
]
=
http
->
hd
[
HTTP_HDR_URL
].
b
;
s
->
n
=
1
;
s
->
p
=
sp
;
return
(
VRT_HashStrands32
(
s
));
return
(
VRT_HashStrands32
(
TOSTRAND
(
http
->
hd
[
HTTP_HDR_URL
].
b
)));
}
WRONG
(
"by enum"
);
}
...
...
vmod/vmod_directors_shard_cfg.c
View file @
9f5044eb
...
...
@@ -270,8 +270,6 @@ shardcfg_hashcircle(struct sharddir *shardd)
const
char
*
ident
;
const
int
len
=
12
;
// log10(UINT32_MAX) + 2;
char
s
[
len
];
struct
strands
ss
[
1
];
const
char
*
ssp
[
2
];
CHECK_OBJ_NOTNULL
(
shardd
,
SHARDDIR_MAGIC
);
AZ
(
shardd
->
hashcircle
);
...
...
@@ -309,12 +307,9 @@ shardcfg_hashcircle(struct sharddir *shardd)
for
(
j
=
0
;
j
<
r
;
j
++
)
{
assert
(
snprintf
(
s
,
len
,
"%d"
,
j
)
<
len
);
ss
->
n
=
2
;
ssp
[
0
]
=
ident
;
ssp
[
1
]
=
s
;
ss
->
p
=
ssp
;
assert
(
i
<
n_points
);
shardd
->
hashcircle
[
i
].
point
=
VRT_HashStrands32
(
ss
);
shardd
->
hashcircle
[
i
].
point
=
VRT_HashStrands32
(
TOSTRANDS
(
2
,
ident
,
s
));
shardd
->
hashcircle
[
i
].
host
=
h
;
i
++
;
}
...
...
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