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
d9c19168
Commit
d9c19168
authored
May 14, 2015
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a per-method specific pointer to the vrt-context, and use
it to slim down req/busyobj a tiny bit.
parent
303f5609
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
56 additions
and
69 deletions
+56
-69
cache.h
bin/varnishd/cache/cache.h
+1
-9
cache_deliver_proc.c
bin/varnishd/cache/cache_deliver_proc.c
+0
-1
cache_fetch.c
bin/varnishd/cache/cache_fetch.c
+14
-14
cache_hash.c
bin/varnishd/cache/cache_hash.c
+4
-4
cache_req_fsm.c
bin/varnishd/cache/cache_req_fsm.c
+19
-23
cache_vcl.c
bin/varnishd/cache/cache_vcl.c
+5
-4
cache_vrt.c
bin/varnishd/cache/cache_vrt.c
+5
-13
hash_slinger.h
bin/varnishd/hash/hash_slinger.h
+1
-1
vrt.h
include/vrt.h
+7
-0
No files found.
bin/varnishd/cache/cache.h
View file @
d9c19168
...
...
@@ -98,7 +98,6 @@ enum {
/*--------------------------------------------------------------------*/
struct
SHA256Context
;
struct
VSC_C_lck
;
struct
ban
;
struct
busyobj
;
...
...
@@ -518,8 +517,6 @@ struct busyobj {
struct
vsl_log
vsl
[
1
];
struct
vsb
*
synth_body
;
uint8_t
digest
[
DIGEST_LEN
];
struct
vrt_privs
privs
[
1
];
};
...
...
@@ -592,8 +589,6 @@ struct req {
struct
ws
ws
[
1
];
struct
objcore
*
objcore
;
struct
objcore
*
stale_oc
;
/* Lookup stuff */
struct
SHA256Context
*
sha256ctx
;
/* ESI delivery stuff */
ssize_t
l_crc
;
...
...
@@ -619,9 +614,6 @@ struct req {
/* Temporary accounting */
struct
acct_req
acct
;
/* Synth content in vcl_synth */
struct
vsb
*
synth_body
;
};
/*--------------------------------------------------------------------
...
...
@@ -1086,7 +1078,7 @@ const char *VCL_Method_Name(unsigned);
#define VCL_MET_MAC(l,u,b) \
void VCL_##l##_method(struct VCL_conf *, struct worker *, struct req *, \
struct busyobj *bo);
struct busyobj *bo
, void *specific
);
#include "tbl/vcl_returns.h"
#undef VCL_MET_MAC
...
...
bin/varnishd/cache/cache_deliver_proc.c
View file @
d9c19168
...
...
@@ -115,7 +115,6 @@ VDP_DeliverObj(struct req *req)
oi
=
ObjIterBegin
(
req
->
wrk
,
req
->
objcore
);
XXXAN
(
oi
);
AZ
(
req
->
synth_body
);
do
{
ois
=
ObjIter
(
req
->
objcore
,
oi
,
&
ptr
,
&
len
);
...
...
bin/varnishd/cache/cache_fetch.c
View file @
d9c19168
...
...
@@ -274,7 +274,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
http_PrintfHeader
(
bo
->
bereq
,
"X-Varnish: %u"
,
VXID
(
bo
->
vsl
->
wid
));
VCL_backend_fetch_method
(
bo
->
vcl
,
wrk
,
NULL
,
bo
);
VCL_backend_fetch_method
(
bo
->
vcl
,
wrk
,
NULL
,
bo
,
NULL
);
bo
->
uncacheable
=
bo
->
do_pass
;
if
(
wrk
->
handling
==
VCL_RET_ABANDON
)
...
...
@@ -426,7 +426,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
bo
->
vfc
->
http
=
bo
->
beresp
;
bo
->
vfc
->
esi_req
=
bo
->
bereq
;
VCL_backend_response_method
(
bo
->
vcl
,
wrk
,
NULL
,
bo
);
VCL_backend_response_method
(
bo
->
vcl
,
wrk
,
NULL
,
bo
,
NULL
);
if
(
wrk
->
handling
==
VCL_RET_ABANDON
)
{
bo
->
doclose
=
SC_RESP_CLOSE
;
...
...
@@ -770,6 +770,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
ssize_t
l
,
ll
,
o
;
double
now
;
uint8_t
*
ptr
;
struct
vsb
*
synth_body
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
...
...
@@ -780,9 +781,8 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
AN
(
bo
->
fetch_objcore
->
flags
&
OC_F_BUSY
);
AZ
(
bo
->
synth_body
);
bo
->
synth_body
=
VSB_new_auto
();
AN
(
bo
->
synth_body
);
synth_body
=
VSB_new_auto
();
AN
(
synth_body
);
// XXX: reset all beresp flags ?
...
...
@@ -796,13 +796,12 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
bo
->
fetch_objcore
->
exp
.
grace
=
0
;
bo
->
fetch_objcore
->
exp
.
keep
=
0
;
VCL_backend_error_method
(
bo
->
vcl
,
wrk
,
NULL
,
bo
);
VCL_backend_error_method
(
bo
->
vcl
,
wrk
,
NULL
,
bo
,
synth_body
);
AZ
(
VSB_finish
(
bo
->
synth_body
));
AZ
(
VSB_finish
(
synth_body
));
if
(
wrk
->
handling
==
VCL_RET_RETRY
)
{
VSB_delete
(
bo
->
synth_body
);
bo
->
synth_body
=
NULL
;
VSB_delete
(
synth_body
);
bo
->
doclose
=
SC_RESP_CLOSE
;
if
(
bo
->
director_state
!=
DIR_S_NULL
)
...
...
@@ -822,22 +821,23 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
bo
->
vfc
->
http
=
bo
->
beresp
;
bo
->
vfc
->
esi_req
=
bo
->
bereq
;
if
(
vbf_beresp2obj
(
bo
))
if
(
vbf_beresp2obj
(
bo
))
{
VSB_delete
(
synth_body
);
return
(
F_STP_FAIL
);
}
ll
=
VSB_len
(
bo
->
synth_body
);
ll
=
VSB_len
(
synth_body
);
o
=
0
;
while
(
ll
>
0
)
{
l
=
ll
;
if
(
VFP_GetStorage
(
bo
->
vfc
,
&
l
,
&
ptr
)
!=
VFP_OK
)
break
;
memcpy
(
ptr
,
VSB_data
(
bo
->
synth_body
)
+
o
,
l
);
memcpy
(
ptr
,
VSB_data
(
synth_body
)
+
o
,
l
);
VBO_extend
(
bo
,
l
);
ll
-=
l
;
o
+=
l
;
}
VSB_delete
(
bo
->
synth_body
);
bo
->
synth_body
=
NULL
;
VSB_delete
(
synth_body
);
HSH_Unbusy
(
wrk
,
bo
->
fetch_objcore
);
VBO_setstate
(
bo
,
BOS_FINISHED
);
...
...
bin/varnishd/cache/cache_hash.c
View file @
d9c19168
...
...
@@ -187,16 +187,16 @@ HSH_DeleteObjHead(struct worker *wrk, struct objhead *oh)
}
void
HSH_AddString
(
struct
req
*
req
,
const
char
*
str
)
HSH_AddString
(
struct
req
*
req
,
void
*
ctx
,
const
char
*
str
)
{
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
AN
(
req
->
sha256
ctx
);
AN
(
ctx
);
if
(
str
!=
NULL
)
{
SHA256_Update
(
req
->
sha256
ctx
,
str
,
strlen
(
str
));
SHA256_Update
(
ctx
,
str
,
strlen
(
str
));
VSLb
(
req
->
vsl
,
SLT_Hash
,
"%s"
,
str
);
}
else
SHA256_Update
(
req
->
sha256ctx
,
&
str
,
sizeof
str
);
SHA256_Update
(
ctx
,
&
str
,
1
);
}
/*---------------------------------------------------------------------
...
...
bin/varnishd/cache/cache_req_fsm.c
View file @
d9c19168
...
...
@@ -133,7 +133,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
!
RFC2616_Req_Gzip
(
req
->
http
))
RFC2616_Weaken_Etag
(
req
->
resp
);
VCL_deliver_method
(
req
->
vcl
,
wrk
,
req
,
NULL
);
VCL_deliver_method
(
req
->
vcl
,
wrk
,
req
,
NULL
,
NULL
);
VSLb_ts_req
(
req
,
"Process"
,
W_TIM_real
(
wrk
));
/* Stop the insanity before it turns "Hotel California" on us */
...
...
@@ -211,6 +211,7 @@ cnt_synth(struct worker *wrk, struct req *req)
{
struct
http
*
h
;
double
now
;
struct
vsb
*
synth_body
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
...
...
@@ -231,23 +232,21 @@ cnt_synth(struct worker *wrk, struct req *req)
http_PrintfHeader
(
req
->
resp
,
"X-Varnish: %u"
,
VXID
(
req
->
vsl
->
wid
));
http_PutResponse
(
h
,
"HTTP/1.1"
,
req
->
err_code
,
req
->
err_reason
);
AZ
(
req
->
synth_body
);
req
->
synth_body
=
VSB_new_auto
();
AN
(
req
->
synth_body
);
synth_body
=
VSB_new_auto
();
AN
(
synth_body
);
VCL_synth_method
(
req
->
vcl
,
wrk
,
req
,
NULL
);
VCL_synth_method
(
req
->
vcl
,
wrk
,
req
,
NULL
,
synth_body
);
http_Unset
(
h
,
H_Content_Length
);
AZ
(
VSB_finish
(
req
->
synth_body
));
AZ
(
VSB_finish
(
synth_body
));
/* Discard any lingering request body before delivery */
(
void
)
VRB_Ignore
(
req
);
if
(
wrk
->
handling
==
VCL_RET_RESTART
)
{
HTTP_Setup
(
h
,
req
->
ws
,
req
->
vsl
,
SLT_RespMethod
);
VSB_delete
(
req
->
synth_body
);
req
->
synth_body
=
NULL
;
VSB_delete
(
synth_body
);
req
->
req_step
=
R_STP_RESTART
;
return
(
REQ_FSM_MORE
);
}
...
...
@@ -262,21 +261,20 @@ cnt_synth(struct worker *wrk, struct req *req)
ssize_t
sz
,
szl
;
uint8_t
*
ptr
;
szl
=
VSB_len
(
req
->
synth_body
);
szl
=
VSB_len
(
synth_body
);
assert
(
szl
>=
0
);
if
(
szl
>
0
)
{
sz
=
szl
;
AN
(
ObjGetSpace
(
wrk
,
req
->
objcore
,
&
sz
,
&
ptr
));
assert
(
sz
>=
szl
);
memcpy
(
ptr
,
VSB_data
(
req
->
synth_body
),
szl
);
memcpy
(
ptr
,
VSB_data
(
synth_body
),
szl
);
ObjExtend
(
wrk
,
req
->
objcore
,
szl
);
}
VSB_delete
(
req
->
synth_body
);
req
->
synth_body
=
NULL
;
cnt_vdp
(
req
,
NULL
);
(
void
)
HSH_DerefObjCore
(
wrk
,
&
req
->
objcore
);
}
VSB_delete
(
synth_body
);
VSLb_ts_req
(
req
,
"Resp"
,
W_TIM_real
(
wrk
));
...
...
@@ -388,7 +386,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
VSLb
(
req
->
vsl
,
SLT_Hit
,
"%u"
,
ObjGetXID
(
wrk
,
req
->
objcore
));
VCL_hit_method
(
req
->
vcl
,
wrk
,
req
,
NULL
);
VCL_hit_method
(
req
->
vcl
,
wrk
,
req
,
NULL
,
NULL
);
switch
(
wrk
->
handling
)
{
case
VCL_RET_DELIVER
:
...
...
@@ -463,7 +461,7 @@ cnt_miss(struct worker *wrk, struct req *req)
CHECK_OBJ_NOTNULL
(
req
->
vcl
,
VCL_CONF_MAGIC
);
CHECK_OBJ_NOTNULL
(
req
->
objcore
,
OBJCORE_MAGIC
);
VCL_miss_method
(
req
->
vcl
,
wrk
,
req
,
NULL
);
VCL_miss_method
(
req
->
vcl
,
wrk
,
req
,
NULL
,
NULL
);
switch
(
wrk
->
handling
)
{
case
VCL_RET_FETCH
:
wrk
->
stats
->
cache_miss
++
;
...
...
@@ -504,7 +502,7 @@ cnt_pass(struct worker *wrk, struct req *req)
CHECK_OBJ_NOTNULL
(
req
->
vcl
,
VCL_CONF_MAGIC
);
AZ
(
req
->
objcore
);
VCL_pass_method
(
req
->
vcl
,
wrk
,
req
,
NULL
);
VCL_pass_method
(
req
->
vcl
,
wrk
,
req
,
NULL
,
NULL
);
switch
(
wrk
->
handling
)
{
case
VCL_RET_SYNTH
:
req
->
req_step
=
R_STP_SYNTH
;
...
...
@@ -550,7 +548,7 @@ cnt_pipe(struct worker *wrk, struct req *req)
http_PrintfHeader
(
bo
->
bereq
,
"X-Varnish: %u"
,
VXID
(
req
->
vsl
->
wid
));
http_SetHeader
(
bo
->
bereq
,
"Connection: close"
);
VCL_pipe_method
(
req
->
vcl
,
wrk
,
req
,
bo
);
VCL_pipe_method
(
req
->
vcl
,
wrk
,
req
,
bo
,
NULL
);
if
(
wrk
->
handling
==
VCL_RET_SYNTH
)
INCOMPL
();
...
...
@@ -651,7 +649,7 @@ cnt_recv(struct worker *wrk, struct req *req)
http_CollectHdr
(
req
->
http
,
H_Cache_Control
);
VCL_recv_method
(
req
->
vcl
,
wrk
,
req
,
NULL
);
VCL_recv_method
(
req
->
vcl
,
wrk
,
req
,
NULL
,
NULL
);
/* Attempts to cache req.body may fail */
if
(
req
->
req_body_status
==
REQ_BODY_FAIL
)
{
...
...
@@ -672,12 +670,10 @@ cnt_recv(struct worker *wrk, struct req *req)
}
}
req
->
sha256ctx
=
&
sha256ctx
;
/* so HSH_AddString() can find it */
SHA256_Init
(
req
->
sha256ctx
);
VCL_hash_method
(
req
->
vcl
,
wrk
,
req
,
NULL
);
SHA256_Init
(
&
sha256ctx
);
VCL_hash_method
(
req
->
vcl
,
wrk
,
req
,
NULL
,
&
sha256ctx
);
assert
(
wrk
->
handling
==
VCL_RET_LOOKUP
);
SHA256_Final
(
req
->
digest
,
req
->
sha256ctx
);
req
->
sha256ctx
=
NULL
;
SHA256_Final
(
req
->
digest
,
&
sha256ctx
);
if
(
!
strcmp
(
req
->
http
->
hd
[
HTTP_HDR_METHOD
].
b
,
"HEAD"
))
req
->
wantbody
=
0
;
...
...
@@ -743,7 +739,7 @@ cnt_purge(struct worker *wrk, struct req *req)
AZ
(
HSH_DerefObjCore
(
wrk
,
&
boc
));
VCL_purge_method
(
req
->
vcl
,
wrk
,
req
,
NULL
);
VCL_purge_method
(
req
->
vcl
,
wrk
,
req
,
NULL
,
NULL
);
switch
(
wrk
->
handling
)
{
case
VCL_RET_RESTART
:
req
->
req_step
=
R_STP_RESTART
;
...
...
bin/varnishd/cache/cache_vcl.c
View file @
d9c19168
...
...
@@ -461,7 +461,7 @@ ccf_config_show(struct cli *cli, const char * const *av, void *priv)
static
void
vcl_call_method
(
struct
worker
*
wrk
,
struct
req
*
req
,
struct
busyobj
*
bo
,
unsigned
method
,
vcl_func_f
*
func
)
void
*
specific
,
unsigned
method
,
vcl_func_f
*
func
)
{
char
*
aws
;
struct
vsl_log
*
vsl
=
NULL
;
...
...
@@ -492,6 +492,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
}
assert
(
ctx
.
now
!=
0
);
ctx
.
vsl
=
vsl
;
ctx
.
specific
=
specific
;
ctx
.
method
=
method
;
ctx
.
handling
=
&
wrk
->
handling
;
aws
=
WS_Snapshot
(
wrk
->
aws
);
...
...
@@ -514,13 +515,13 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
#define VCL_MET_MAC(func, upper, bitmap) \
void \
VCL_##func##_method(struct VCL_conf *vcl, struct worker *wrk, \
struct req *req, struct busyobj *bo
)
\
struct req *req, struct busyobj *bo
, void *specific)
\
{ \
\
CHECK_OBJ_NOTNULL(vcl, VCL_CONF_MAGIC); \
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); \
vcl_call_method(wrk, req, bo,
VCL_MET_ ## upper,
\
vcl->func##_func);
\
vcl_call_method(wrk, req, bo,
specific,
\
VCL_MET_ ## upper, vcl->func##_func);
\
AN((1U << wrk->handling) & bitmap); \
}
...
...
bin/varnishd/cache/cache_vrt.c
View file @
d9c19168
...
...
@@ -264,20 +264,21 @@ VRT_hashdata(VRT_CTX, const char *str, ...)
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
req
,
REQ_MAGIC
);
HSH_AddString
(
ctx
->
req
,
str
);
AN
(
ctx
->
specific
);
HSH_AddString
(
ctx
->
req
,
ctx
->
specific
,
str
);
va_start
(
ap
,
str
);
while
(
1
)
{
p
=
va_arg
(
ap
,
const
char
*
);
if
(
p
==
vrt_magic_string_end
)
break
;
HSH_AddString
(
ctx
->
req
,
p
);
HSH_AddString
(
ctx
->
req
,
ctx
->
specific
,
p
);
}
va_end
(
ap
);
/*
* Add a 'field-separator' to make it more difficult to
* manipulate the hash.
*/
HSH_AddString
(
ctx
->
req
,
NULL
);
HSH_AddString
(
ctx
->
req
,
ctx
->
specific
,
NULL
);
}
/*--------------------------------------------------------------------*/
...
...
@@ -386,16 +387,7 @@ VRT_synth_page(VRT_CTX, const char *str, ...)
const
char
*
p
;
struct
vsb
*
vsb
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
if
(
ctx
->
method
==
VCL_MET_BACKEND_ERROR
)
{
CHECK_OBJ_NOTNULL
(
ctx
->
bo
,
BUSYOBJ_MAGIC
);
vsb
=
ctx
->
bo
->
synth_body
;
}
else
{
CHECK_OBJ_NOTNULL
(
ctx
->
req
,
REQ_MAGIC
);
vsb
=
ctx
->
req
->
synth_body
;
}
AN
(
vsb
);
CAST_OBJ_NOTNULL
(
vsb
,
ctx
->
specific
,
VSB_MAGIC
);
va_start
(
ap
,
str
);
p
=
str
;
while
(
p
!=
vrt_magic_string_end
)
{
...
...
bin/varnishd/hash/hash_slinger.h
View file @
d9c19168
...
...
@@ -67,7 +67,7 @@ enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **,
int
wait_for_busy
,
int
always_insert
);
void
HSH_Ref
(
struct
objcore
*
o
);
void
HSH_Init
(
const
struct
hash_slinger
*
slinger
);
void
HSH_AddString
(
struct
req
*
,
const
char
*
str
);
void
HSH_AddString
(
struct
req
*
,
void
*
ctx
,
const
char
*
str
);
void
HSH_Insert
(
struct
worker
*
,
const
void
*
hash
,
struct
objcore
*
);
void
HSH_Purge
(
struct
worker
*
,
struct
objhead
*
,
double
ttl
,
double
grace
,
double
keep
);
...
...
include/vrt.h
View file @
d9c19168
...
...
@@ -107,6 +107,13 @@ struct vrt_ctx {
struct
http
*
http_beresp
;
double
now
;
/*
* method specific argument:
* hash: struct SHA256ctx
* synth+error: struct vsb *
*/
void
*
specific
;
};
#define VRT_CTX const struct vrt_ctx *ctx
...
...
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