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
2e3b542d
Commit
2e3b542d
authored
Apr 30, 2013
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the VRT_[GS]etHdr() take vrt_ctx arg.
parent
8a3dfdf3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
33 deletions
+44
-33
cache_vcl.c
bin/varnishd/cache/cache_vcl.c
+16
-8
cache_vrt.c
bin/varnishd/cache/cache_vrt.c
+17
-16
vrt.h
include/vrt.h
+2
-2
generate.py
lib/libvcl/generate.py
+7
-5
vcc_expr.c
lib/libvcl/vcc_expr.c
+1
-1
vcc_var.c
lib/libvcl/vcc_var.c
+1
-1
No files found.
bin/varnishd/cache/cache_vcl.c
View file @
2e3b542d
...
...
@@ -376,7 +376,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
struct
ws
*
ws
,
unsigned
method
,
vcl_func_f
*
func
)
{
char
*
aws
;
struct
vsl_log
*
vsl
;
struct
vsl_log
*
vsl
=
NULL
;
struct
vrt_ctx
ctx
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
...
...
@@ -389,14 +389,11 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
vsl
=
req
->
vsl
;
ctx
.
vsl
=
vsl
;
ctx
.
vcl
=
req
->
vcl
;
}
else
{
AZ
(
req
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
vsl
=
bo
->
vsl
;
ctx
.
vsl
=
vsl
;
ctx
.
vcl
=
bo
->
vcl
;
ctx
.
http_req
=
req
->
http
;
ctx
.
http_resp
=
req
->
resp
;
if
(
req
->
obj
)
ctx
.
http_obj
=
req
->
obj
->
http
;
}
ctx
.
ws
=
ws
;
if
(
method
==
VCL_MET_BACKEND_FETCH
||
method
==
VCL_MET_PASS
||
method
==
VCL_MET_MISS
||
...
...
@@ -407,9 +404,20 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
bo
=
req
->
busyobj
;
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
}
if
(
bo
!=
NULL
)
{
// AZ(req);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
vsl
=
bo
->
vsl
;
ctx
.
vsl
=
vsl
;
ctx
.
vcl
=
bo
->
vcl
;
ctx
.
http_bereq
=
bo
->
bereq
;
ctx
.
http_beresp
=
bo
->
beresp
;
}
ctx
.
ws
=
ws
;
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
,
req
,
bo
,
ws
);
VSLb
(
vsl
,
SLT_VCL_return
,
"%s"
,
VCL_Return_Name
(
wrk
->
handling
));
...
...
bin/varnishd/cache/cache_vrt.c
View file @
2e3b542d
...
...
@@ -107,43 +107,42 @@ VRT_acl_log(struct req *req, const char *msg)
/*--------------------------------------------------------------------*/
static
struct
http
*
vrt_selecthttp
(
const
struct
req
*
req
,
enum
gethdr_e
where
)
vrt_selecthttp
(
const
struct
vrt_ctx
*
ctx
,
enum
gethdr_e
where
)
{
struct
http
*
hp
;
CHECK_OBJ_NOTNULL
(
req
,
REQ
_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX
_MAGIC
);
switch
(
where
)
{
case
HDR_REQ
:
hp
=
req
->
http
;
hp
=
ctx
->
http_req
;
break
;
case
HDR_BEREQ
:
hp
=
req
->
busyobj
->
bereq
;
hp
=
ctx
->
http_
bereq
;
break
;
case
HDR_BERESP
:
hp
=
req
->
busyobj
->
beresp
;
hp
=
ctx
->
http_
beresp
;
break
;
case
HDR_RESP
:
hp
=
req
->
resp
;
hp
=
ctx
->
http_
resp
;
break
;
case
HDR_OBJ
:
CHECK_OBJ_NOTNULL
(
req
->
obj
,
OBJECT_MAGIC
);
hp
=
req
->
obj
->
http
;
hp
=
ctx
->
http_obj
;
break
;
default:
INCOMPL
();
}
CHECK_OBJ_NOTNULL
(
hp
,
HTTP_MAGIC
);
return
(
hp
);
}
char
*
VRT_GetHdr
(
const
struct
req
*
req
,
const
struct
gethdr_s
*
hs
)
VRT_GetHdr
(
const
struct
vrt_ctx
*
ctx
,
const
struct
gethdr_s
*
hs
)
{
char
*
p
;
struct
http
*
hp
;
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
hp
=
vrt_selecthttp
(
req
,
hs
->
where
);
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
hp
=
vrt_selecthttp
(
ctx
,
hs
->
where
);
CHECK_OBJ_NOTNULL
(
hp
,
HTTP_MAGIC
);
if
(
!
http_GetHdr
(
hp
,
hs
->
what
,
&
p
))
return
(
NULL
);
return
(
p
);
...
...
@@ -229,23 +228,25 @@ VRT_CollectString(struct ws *ws, const char *p, ...)
/*--------------------------------------------------------------------*/
void
VRT_SetHdr
(
struct
req
*
req
,
const
struct
gethdr_s
*
hs
,
const
char
*
p
,
...)
VRT_SetHdr
(
const
struct
vrt_ctx
*
ctx
,
const
struct
gethdr_s
*
hs
,
const
char
*
p
,
...)
{
struct
http
*
hp
;
va_list
ap
;
char
*
b
;
CHECK_OBJ_NOTNULL
(
req
,
REQ
_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX
_MAGIC
);
AN
(
hs
);
AN
(
hs
->
what
);
hp
=
vrt_selecthttp
(
req
,
hs
->
where
);
hp
=
vrt_selecthttp
(
ctx
,
hs
->
where
);
CHECK_OBJ_NOTNULL
(
hp
,
HTTP_MAGIC
);
va_start
(
ap
,
p
);
if
(
p
==
vrt_magic_string_unset
)
{
http_Unset
(
hp
,
hs
->
what
);
}
else
{
b
=
VRT_String
(
hp
->
ws
,
hs
->
what
+
1
,
p
,
ap
);
if
(
b
==
NULL
)
{
VSLb
(
req
->
vsl
,
SLT_LostHeader
,
"%s"
,
hs
->
what
+
1
);
VSLb
(
ctx
->
vsl
,
SLT_LostHeader
,
"%s"
,
hs
->
what
+
1
);
}
else
{
http_Unset
(
hp
,
hs
->
what
);
http_SetHeader
(
hp
,
b
);
...
...
include/vrt.h
View file @
2e3b542d
...
...
@@ -204,8 +204,8 @@ void VRT_error(struct req *, unsigned, const char *);
int
VRT_switch_config
(
const
char
*
);
const
struct
gethdr_s
*
VRT_MkGethdr
(
struct
req
*
,
enum
gethdr_e
,
const
char
*
);
char
*
VRT_GetHdr
(
const
struct
req
*
,
const
struct
gethdr_s
*
);
void
VRT_SetHdr
(
struct
req
*
,
const
struct
gethdr_s
*
,
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_hashdata
(
struct
req
*
,
const
char
*
str
,
...);
...
...
lib/libvcl/generate.py
View file @
2e3b542d
...
...
@@ -165,7 +165,7 @@ sp_variables = (
'HEADER'
,
(
'client'
,),
(
'client'
,),
'
cR
'
'
C
'
),
(
'req.restarts'
,
'INT'
,
...
...
@@ -279,7 +279,7 @@ sp_variables = (
'HEADER'
,
(
'pipe'
,
'backend_fetch'
,
'pass'
,
'miss'
,
'backend_response'
,),
(
'pipe'
,
'backend_fetch'
,
'pass'
,
'miss'
,
'backend_response'
,),
'
cR
'
'
C
'
),
(
'bereq.connect_timeout'
,
'DURATION'
,
...
...
@@ -327,7 +327,7 @@ sp_variables = (
'HEADER'
,
(
'backend_response'
,),
(
'backend_response'
,),
'
cR
'
'
C
'
),
(
'beresp.do_esi'
,
'BOOL'
,
...
...
@@ -435,7 +435,7 @@ sp_variables = (
'HEADER'
,
(
'lookup'
,
'error'
,),
(
'error'
,),
# XXX ?
'
cR
'
'
C
'
),
(
'obj.ttl'
,
'DURATION'
,
...
...
@@ -489,7 +489,7 @@ sp_variables = (
'HEADER'
,
(
'deliver'
,),
(
'deliver'
,),
'
cR
'
'
C
'
),
(
'now'
,
'TIME'
,
...
...
@@ -885,6 +885,8 @@ def mk_proto(c, r=False):
s
+=
" const"
elif
i
==
"c"
:
pass
elif
i
==
"C"
:
s
+=
"const struct vrt_ctx *"
elif
i
==
"R"
:
if
r
:
s
+=
" const"
...
...
lib/libvcl/vcc_expr.c
View file @
2e3b542d
...
...
@@ -418,7 +418,7 @@ vcc_expr_tostring(struct expr **e, enum var_type fmt)
case
BYTES
:
p
=
"VRT_REAL_string(ws,
\v
1)"
;
break
;
/* XXX */
case
REAL
:
p
=
"VRT_REAL_string(ws,
\v
1)"
;
break
;
case
TIME
:
p
=
"VRT_TIME_string(ws,
\v
1)"
;
break
;
case
HEADER
:
p
=
"VRT_GetHdr(
req
,
\v
1)"
;
break
;
case
HEADER
:
p
=
"VRT_GetHdr(
ctx
,
\v
1)"
;
break
;
case
ENUM
:
case
STRING
:
case
STRING_LIST
:
...
...
lib/libvcl/vcc_var.c
View file @
2e3b542d
...
...
@@ -78,7 +78,7 @@ vcc_Var_Wildcard(struct vcc *tl, const struct token *t, const struct symbol *wc)
bprintf
(
buf
,
"&VGC_%s_%s"
,
vh
->
rname
,
cnam
);
v
->
rname
=
TlDup
(
tl
,
buf
);
bprintf
(
buf
,
"VRT_SetHdr(
req
, %s, "
,
v
->
rname
);
bprintf
(
buf
,
"VRT_SetHdr(
ctx
, %s, "
,
v
->
rname
);
v
->
lname
=
TlDup
(
tl
,
buf
);
sym
=
VCC_AddSymbolTok
(
tl
,
t
,
SYM_VAR
);
...
...
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