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
b6da2dc7
Commit
b6da2dc7
authored
May 01, 2013
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the wrk argument from VCL/VRT, now everything we need is
encapsulated in the vrt_ctx.
parent
b3e1e100
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
26 deletions
+32
-26
cache_vcl.c
bin/varnishd/cache/cache_vcl.c
+13
-3
cache_vrt.c
bin/varnishd/cache/cache_vrt.c
+6
-12
c00033.vtc
bin/varnishtest/tests/c00033.vtc
+2
-2
vrt.h
include/vrt.h
+6
-3
generate.py
lib/libvcl/generate.py
+1
-1
vcc_action.c
lib/libvcl/vcc_action.c
+3
-3
vcc_compile.c
lib/libvcl/vcc_compile.c
+1
-2
No files found.
bin/varnishd/cache/cache_vcl.c
View file @
b6da2dc7
...
...
@@ -174,6 +174,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli)
struct
vcls
*
vcl
;
struct
VCL_conf
const
*
cnf
;
struct
vrt_ctx
ctx
;
unsigned
hand
=
0
;
ASSERT_CLI
();
...
...
@@ -220,7 +221,10 @@ VCL_Load(const char *fn, const char *name, struct cli *cli)
REPLACE
(
vcl
->
name
,
name
);
VCLI_Out
(
cli
,
"Loaded
\"
%s
\"
as
\"
%s
\"
"
,
fn
,
name
);
VTAILQ_INSERT_TAIL
(
&
vcl_head
,
vcl
,
list
);
(
void
)
vcl
->
conf
->
init_func
(
&
ctx
,
NULL
);
ctx
.
method
=
VCL_MET_INIT
;
ctx
.
handling
=
&
hand
;
(
void
)
vcl
->
conf
->
init_func
(
&
ctx
);
assert
(
hand
==
VCL_RET_OK
);
Lck_Lock
(
&
vcl_mtx
);
if
(
vcl_active
==
NULL
)
vcl_active
=
vcl
;
...
...
@@ -239,6 +243,7 @@ static void
VCL_Nuke
(
struct
vcls
*
vcl
)
{
struct
vrt_ctx
ctx
;
unsigned
hand
=
0
;
memset
(
&
ctx
,
0
,
sizeof
ctx
);
ctx
.
magic
=
VRT_CTX_MAGIC
;
...
...
@@ -247,7 +252,10 @@ VCL_Nuke(struct vcls *vcl)
assert
(
vcl
->
conf
->
discard
);
assert
(
vcl
->
conf
->
busy
==
0
);
VTAILQ_REMOVE
(
&
vcl_head
,
vcl
,
list
);
(
void
)
vcl
->
conf
->
fini_func
(
&
ctx
,
NULL
);
ctx
.
method
=
VCL_MET_FINI
;
ctx
.
handling
=
&
hand
;
(
void
)
vcl
->
conf
->
fini_func
(
&
ctx
);
assert
(
hand
==
VCL_RET_OK
);
vcl
->
conf
->
fini_vcl
(
NULL
);
free
(
vcl
->
name
);
(
void
)
dlclose
(
vcl
->
dlh
);
...
...
@@ -416,12 +424,14 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
ctx
.
bo
=
bo
;
}
ctx
.
ws
=
ws
;
ctx
.
method
=
method
;
ctx
.
handling
=
&
wrk
->
handling
;
aws
=
WS_Snapshot
(
wrk
->
aws
);
wrk
->
handling
=
0
;
wrk
->
cur_method
=
method
;
AN
(
vsl
);
VSLb
(
vsl
,
SLT_VCL_call
,
"%s"
,
VCL_Method_Name
(
method
));
(
void
)
func
(
&
ctx
,
wrk
);
(
void
)
func
(
&
ctx
);
VSLb
(
vsl
,
SLT_VCL_return
,
"%s"
,
VCL_Return_Name
(
wrk
->
handling
));
wrk
->
cur_method
=
0
;
WS_Reset
(
wrk
->
aws
,
aws
);
...
...
bin/varnishd/cache/cache_vrt.c
View file @
b6da2dc7
...
...
@@ -264,16 +264,12 @@ VRT_SetHdr(const struct vrt_ctx *ctx , const struct gethdr_s *hs,
/*--------------------------------------------------------------------*/
void
VRT_handling
(
struct
worker
*
wrk
,
unsigned
hand
)
VRT_handling
(
const
struct
vrt_ctx
*
ctx
,
unsigned
hand
)
{
if
(
wrk
==
NULL
)
{
assert
(
hand
==
VCL_RET_OK
);
return
;
}
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
assert
(
hand
<
VCL_RET_MAX
);
wrk
->
handling
=
hand
;
*
ctx
->
handling
=
hand
;
}
/*--------------------------------------------------------------------
...
...
@@ -516,17 +512,15 @@ VRT_CacheReqBody(const struct vrt_ctx *ctx, long long maxsize)
*/
void
VRT_purge
(
const
struct
worker
*
wrk
,
const
struct
vrt_ctx
*
ctx
,
double
ttl
,
double
grace
)
VRT_purge
(
const
struct
vrt_ctx
*
ctx
,
double
ttl
,
double
grace
)
{
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
req
,
REQ_MAGIC
);
if
(
wrk
->
cur_
method
==
VCL_MET_LOOKUP
)
if
(
ctx
->
method
==
VCL_MET_LOOKUP
)
HSH_Purge
(
ctx
->
req
,
ctx
->
req
->
obj
->
objcore
->
objhead
,
ttl
,
grace
);
else
if
(
wrk
->
cur_
method
==
VCL_MET_MISS
)
else
if
(
ctx
->
method
==
VCL_MET_MISS
)
HSH_Purge
(
ctx
->
req
,
ctx
->
req
->
objcore
->
objhead
,
ttl
,
grace
);
}
...
...
bin/varnishtest/tests/c00033.vtc
View file @
b6da2dc7
...
...
@@ -25,13 +25,13 @@ varnish v1 -vcl+backend {
sub vcl_lookup {
if (req.method == "PURGE") {
C{ VRT_purge(
wrk,
ctx, 0, 0); }C
C{ VRT_purge(ctx, 0, 0); }C
error 456 "got it";
}
}
sub vcl_miss {
if (req.method == "PURGE") {
C{ VRT_purge(
wrk,
ctx, 0, 0); }C
C{ VRT_purge(ctx, 0, 0); }C
error 456 "got it";
}
}
...
...
include/vrt.h
View file @
b6da2dc7
...
...
@@ -70,6 +70,9 @@ struct vrt_ctx {
unsigned
magic
;
#define VRT_CTX_MAGIC 0x6bb8f0db
unsigned
method
;
unsigned
*
handling
;
struct
vsl_log
*
vsl
;
struct
VCL_conf
*
vcl
;
struct
ws
*
ws
;
...
...
@@ -82,6 +85,7 @@ struct vrt_ctx {
struct
busyobj
*
bo
;
struct
http
*
http_bereq
;
struct
http
*
http_beresp
;
};
/***********************************************************************/
...
...
@@ -196,8 +200,7 @@ const char *VRT_regsub(const struct vrt_ctx *, int all, const char *,
void
*
,
const
char
*
);
void
VRT_ban_string
(
const
char
*
);
void
VRT_purge
(
const
struct
worker
*
,
const
struct
vrt_ctx
*
,
double
ttl
,
double
grace
);
void
VRT_purge
(
const
struct
vrt_ctx
*
,
double
ttl
,
double
grace
);
void
VRT_count
(
const
struct
vrt_ctx
*
,
unsigned
);
int
VRT_rewrite
(
const
char
*
,
const
char
*
);
...
...
@@ -208,7 +211,7 @@ const struct gethdr_s *VRT_MkGethdr(const struct vrt_ctx *,enum gethdr_e,
const
char
*
);
char
*
VRT_GetHdr
(
const
struct
vrt_ctx
*
,
const
struct
gethdr_s
*
);
void
VRT_SetHdr
(
const
struct
vrt_ctx
*
,
const
struct
gethdr_s
*
,
const
char
*
,
...);
void
VRT_handling
(
struct
worker
*
,
unsigned
hand
);
void
VRT_handling
(
const
struct
vrt_ctx
*
,
unsigned
hand
);
void
VRT_hashdata
(
const
struct
vrt_ctx
*
,
const
char
*
str
,
...);
...
...
lib/libvcl/generate.py
View file @
b6da2dc7
...
...
@@ -707,7 +707,7 @@ struct worker;
typedef int vcl_init_f(struct cli *);
typedef void vcl_fini_f(struct cli *);
typedef int vcl_func_f(const struct vrt_ctx *ctx
, struct worker *
);
typedef int vcl_func_f(const struct vrt_ctx *ctx);
"""
)
...
...
lib/libvcl/vcc_action.c
View file @
b6da2dc7
...
...
@@ -79,7 +79,7 @@ parse_error(struct vcc *tl)
Fb
(
tl
,
1
,
", 0
\n
"
);
}
Fb
(
tl
,
1
,
");
\n
"
);
Fb
(
tl
,
1
,
"VRT_handling(
wrk
, VCL_RET_ERROR);
\n
"
);
Fb
(
tl
,
1
,
"VRT_handling(
ctx
, VCL_RET_ERROR);
\n
"
);
Fb
(
tl
,
1
,
"return(1);
\n
"
);
}
...
...
@@ -314,7 +314,7 @@ parse_return(struct vcc *tl)
#define VCL_RET_MAC(l, U, B) \
do { \
if (vcc_IdIs(tl->t, #l)) { \
Fb(tl, 1, "VRT_handling(
wrk
, VCL_RET_" #U ");\n"); \
Fb(tl, 1, "VRT_handling(
ctx
, VCL_RET_" #U ");\n"); \
Fb(tl, 1, "return (1);\n"); \
vcc_ProcAction(tl->curproc, VCL_RET_##U, tl->t);\
retval = 1; \
...
...
@@ -349,7 +349,7 @@ parse_purge(struct vcc *tl)
{
vcc_NextToken
(
tl
);
Fb
(
tl
,
1
,
"VRT_purge(
wrk,
ctx, 0, 0);
\n
"
);
Fb
(
tl
,
1
,
"VRT_purge(ctx, 0, 0);
\n
"
);
}
/*--------------------------------------------------------------------*/
...
...
lib/libvcl/vcc_compile.c
View file @
b6da2dc7
...
...
@@ -693,8 +693,7 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp)
for
(
i
=
0
;
i
<
VCL_MET_MAX
;
i
++
)
{
Fc
(
tl
,
1
,
"
\n
static int __match_proto__(vcl_func_f)
\n
"
);
Fc
(
tl
,
1
,
"VGC_function_%s(const struct vrt_ctx *ctx,"
" struct worker *wrk)
\n
"
,
"VGC_function_%s(const struct vrt_ctx *ctx)
\n
"
,
method_tab
[
i
].
name
);
AZ
(
VSB_finish
(
tl
->
fm
[
i
]));
Fc
(
tl
,
1
,
"{
\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