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
58db58be
Commit
58db58be
authored
Sep 16, 2014
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final refactoring of struct worker as context for Obj*()
parent
7816feec
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
45 deletions
+47
-45
cache.h
bin/varnishd/cache/cache.h
+8
-7
cache_esi_fetch.c
bin/varnishd/cache/cache_esi_fetch.c
+2
-1
cache_fetch.c
bin/varnishd/cache/cache_fetch.c
+12
-11
cache_gzip.c
bin/varnishd/cache/cache_gzip.c
+1
-1
cache_obj.c
bin/varnishd/cache/cache_obj.c
+22
-22
storage.h
bin/varnishd/storage/storage.h
+2
-3
No files found.
bin/varnishd/cache/cache.h
View file @
58db58be
...
...
@@ -992,20 +992,21 @@ void ObjSlim(struct worker *, struct objcore *oc);
struct
lru
*
ObjGetLRU
(
const
struct
objcore
*
);
void
*
ObjGetattr
(
struct
worker
*
wrk
,
struct
objcore
*
oc
,
enum
obj_attr
attr
,
ssize_t
*
len
);
void
*
ObjSetattr
(
const
struct
vfp_ctx
*
,
enum
obj_attr
attr
,
ssize_t
len
,
const
void
*
);
int
ObjCopyAttr
(
const
struct
vfp_ctx
*
,
struct
objcore
*
,
enum
obj_attr
attr
);
void
*
ObjSetattr
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
attr
,
ssize_t
len
,
const
void
*
);
int
ObjCopyAttr
(
struct
worker
*
,
struct
objcore
*
,
struct
objcore
*
,
enum
obj_attr
attr
);
int
ObjSetDouble
(
const
struct
vfp_ctx
*
,
enum
obj_attr
,
double
);
int
ObjSetU32
(
const
struct
vfp_ctx
*
,
enum
obj_attr
,
uint32_t
);
int
ObjSetU64
(
const
struct
vfp_ctx
*
,
enum
obj_attr
,
uint64_t
);
int
ObjSetDouble
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
,
double
);
int
ObjSetU32
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
,
uint32_t
);
int
ObjSetU64
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
,
uint64_t
);
int
ObjGetDouble
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
,
double
*
);
int
ObjGetU32
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
,
uint32_t
*
);
int
ObjGetU64
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
,
uint64_t
*
);
int
ObjCheckFlag
(
struct
worker
*
,
struct
objcore
*
oc
,
enum
obj_flags
of
);
void
ObjSetFlag
(
const
struct
vfp_ctx
*
vc
,
enum
obj_flags
of
,
int
val
);
void
ObjSetFlag
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_flags
of
,
int
val
);
/* cache_panic.c */
void
PAN_Init
(
void
);
...
...
bin/varnishd/cache/cache_esi_fetch.c
View file @
58db58be
...
...
@@ -118,7 +118,8 @@ vfp_esi_end(struct vfp_ctx *vc, struct vef_priv *vef,
if
(
retval
==
VFP_END
)
{
l
=
VSB_len
(
vsb
);
assert
(
l
>
0
);
p
=
ObjSetattr
(
vc
,
OA_ESIDATA
,
l
,
VSB_data
(
vsb
));
p
=
ObjSetattr
(
vc
->
wrk
,
vc
->
oc
,
OA_ESIDATA
,
l
,
VSB_data
(
vsb
));
if
(
p
==
NULL
)
{
retval
=
VFP_Error
(
vc
,
"Could not allocate storage for esidata"
);
...
...
bin/varnishd/cache/cache_fetch.c
View file @
58db58be
...
...
@@ -133,25 +133,25 @@ vbf_beresp2obj(struct busyobj *bo)
return
(
-
1
);
if
(
vary
!=
NULL
)
{
b
=
ObjSetattr
(
bo
->
vfc
,
OA_VARY
,
varyl
,
VSB_data
(
vary
));
b
=
ObjSetattr
(
bo
->
wrk
,
bo
->
fetch_objcore
,
OA_VARY
,
varyl
,
VSB_data
(
vary
));
VSB_delete
(
vary
);
}
AZ
(
ObjSetU32
(
bo
->
vfc
,
OA_VXID
,
VXID
(
bo
->
vsl
->
wid
)));
AZ
(
ObjSetU32
(
bo
->
wrk
,
bo
->
fetch_objcore
,
OA_VXID
,
VXID
(
bo
->
vsl
->
wid
)));
/* for HTTP_Encode() VSLH call */
bo
->
beresp
->
logtag
=
SLT_ObjMethod
;
/* Filter into object */
bp
=
ObjSetattr
(
bo
->
vfc
,
OA_HEADERS
,
l2
,
NULL
);
bp
=
ObjSetattr
(
bo
->
wrk
,
bo
->
fetch_objcore
,
OA_HEADERS
,
l2
,
NULL
);
AN
(
bp
);
HTTP_Encode
(
bo
->
beresp
,
bp
,
l2
,
bo
->
uncacheable
?
HTTPH_R_PASS
:
HTTPH_A_INS
);
if
(
http_GetHdr
(
bo
->
beresp
,
H_Last_Modified
,
&
b
))
AZ
(
ObjSetDouble
(
bo
->
vfc
,
OA_LASTMODIFIED
,
VTIM_parse
(
b
)));
AZ
(
ObjSetDouble
(
bo
->
wrk
,
bo
->
fetch_objcore
,
OA_LASTMODIFIED
,
VTIM_parse
(
b
)));
else
AZ
(
ObjSetDouble
(
bo
->
vfc
,
OA_LASTMODIFIED
,
AZ
(
ObjSetDouble
(
bo
->
wrk
,
bo
->
fetch_objcore
,
OA_LASTMODIFIED
,
floor
(
bo
->
fetch_objcore
->
exp
.
t_origin
)));
return
(
0
);
...
...
@@ -587,15 +587,15 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
if
(
bo
->
do_gzip
||
(
bo
->
is_gzip
&&
!
bo
->
do_gunzip
))
ObjSetFlag
(
bo
->
vfc
,
OF_GZIPED
,
1
);
ObjSetFlag
(
bo
->
wrk
,
bo
->
fetch_objcore
,
OF_GZIPED
,
1
);
if
(
bo
->
do_gzip
||
bo
->
do_gunzip
)
ObjSetFlag
(
bo
->
vfc
,
OF_CHGGZIP
,
1
);
ObjSetFlag
(
bo
->
wrk
,
bo
->
fetch_objcore
,
OF_CHGGZIP
,
1
);
if
(
http_IsStatus
(
bo
->
beresp
,
200
)
&&
(
http_GetHdr
(
bo
->
beresp
,
H_Last_Modified
,
&
p
)
||
http_GetHdr
(
bo
->
beresp
,
H_ETag
,
&
p
)))
ObjSetFlag
(
bo
->
vfc
,
OF_IMSCAND
,
1
);
ObjSetFlag
(
bo
->
wrk
,
bo
->
fetch_objcore
,
OF_IMSCAND
,
1
);
if
(
bo
->
htc
->
body_status
!=
BS_NONE
)
V1F_Setup_Fetch
(
bo
->
vfc
,
bo
->
htc
);
...
...
@@ -672,10 +672,11 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
AZ
(
vbf_beresp2obj
(
bo
));
if
(
ObjGetattr
(
bo
->
wrk
,
bo
->
ims_oc
,
OA_ESIDATA
,
NULL
)
!=
NULL
)
AZ
(
ObjCopyAttr
(
bo
->
vfc
,
bo
->
ims_oc
,
OA_ESIDATA
));
AZ
(
ObjCopyAttr
(
bo
->
wrk
,
bo
->
fetch_objcore
,
bo
->
ims_oc
,
OA_ESIDATA
));
AZ
(
ObjCopyAttr
(
bo
->
vfc
,
bo
->
ims_oc
,
OA_FLAGS
));
AZ
(
ObjCopyAttr
(
bo
->
vfc
,
bo
->
ims_oc
,
OA_GZIPBITS
));
AZ
(
ObjCopyAttr
(
bo
->
wrk
,
bo
->
fetch_objcore
,
bo
->
ims_oc
,
OA_FLAGS
));
AZ
(
ObjCopyAttr
(
bo
->
wrk
,
bo
->
fetch_objcore
,
bo
->
ims_oc
,
OA_GZIPBITS
));
if
(
bo
->
do_stream
)
{
HSH_Unbusy
(
wrk
,
bo
->
fetch_objcore
);
...
...
bin/varnishd/cache/cache_gzip.c
View file @
58db58be
...
...
@@ -396,7 +396,7 @@ VGZ_UpdateObj(const struct vfp_ctx *vc, const struct vgz *vg)
char
*
p
;
CHECK_OBJ_NOTNULL
(
vg
,
VGZ_MAGIC
);
p
=
ObjSetattr
(
vc
,
OA_GZIPBITS
,
24
,
NULL
);
p
=
ObjSetattr
(
vc
->
wrk
,
vc
->
oc
,
OA_GZIPBITS
,
24
,
NULL
);
AN
(
p
);
vbe64enc
(
p
,
vg
->
vz
.
start_bit
);
vbe64enc
(
p
+
8
,
vg
->
vz
.
last_bit
);
...
...
bin/varnishd/cache/cache_obj.c
View file @
58db58be
...
...
@@ -515,27 +515,25 @@ ObjGetattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr,
*/
void
*
ObjSetattr
(
const
struct
vfp_ctx
*
vc
,
enum
obj_attr
attr
,
ssize_t
len
,
const
void
*
ptr
)
ObjSetattr
(
struct
worker
*
wrk
,
struct
objcore
*
oc
,
enum
obj_attr
attr
,
ssize_t
len
,
const
void
*
ptr
)
{
struct
object
*
o
;
void
*
retval
=
NULL
;
struct
storage
*
st
;
const
struct
storeobj_methods
*
om
=
obj_getmethods
(
vc
->
oc
);
const
struct
storeobj_methods
*
om
=
obj_getmethods
(
oc
);
if
(
om
->
objsetattr
!=
NULL
)
return
(
om
->
objsetattr
(
v
c
,
attr
,
len
,
ptr
));
return
(
om
->
objsetattr
(
wrk
,
o
c
,
attr
,
len
,
ptr
));
CHECK_OBJ_NOTNULL
(
vc
,
VFP_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
vc
->
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
vc
->
oc
,
OBJCORE_MAGIC
);
o
=
obj_getobj
(
vc
->
wrk
,
vc
->
oc
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
o
=
obj_getobj
(
wrk
,
oc
);
CHECK_OBJ_NOTNULL
(
o
,
OBJECT_MAGIC
);
st
=
o
->
objstore
;
switch
(
attr
)
{
case
OA_ESIDATA
:
o
->
esidata
=
objallocwithnuke
(
vc
->
oc
->
stobj
->
stevedore
,
vc
->
wrk
,
len
);
o
->
esidata
=
objallocwithnuke
(
oc
->
stobj
->
stevedore
,
wrk
,
len
);
if
(
o
->
esidata
==
NULL
)
return
(
NULL
);
o
->
esidata
->
len
=
len
;
...
...
@@ -585,18 +583,20 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr, ssize_t len,
*/
int
ObjCopyAttr
(
const
struct
vfp_ctx
*
vc
,
struct
objcore
*
ocs
,
enum
obj_attr
attr
)
ObjCopyAttr
(
struct
worker
*
wrk
,
struct
objcore
*
oc
,
struct
objcore
*
ocs
,
enum
obj_attr
attr
)
{
void
*
vps
,
*
vpd
;
ssize_t
l
;
CHECK_OBJ_NOTNULL
(
vc
,
VFP_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
vps
=
ObjGetattr
(
vc
->
wrk
,
ocs
,
attr
,
&
l
);
vps
=
ObjGetattr
(
wrk
,
ocs
,
attr
,
&
l
);
// XXX: later we want to have zero-length OA's too
if
(
vps
==
NULL
||
l
<=
0
)
return
(
-
1
);
vpd
=
ObjSetattr
(
v
c
,
attr
,
l
,
vps
);
vpd
=
ObjSetattr
(
wrk
,
o
c
,
attr
,
l
,
vps
);
if
(
vpd
==
NULL
)
return
(
-
1
);
return
(
0
);
...
...
@@ -620,14 +620,14 @@ ObjGetXID(struct worker *wrk, struct objcore *oc)
*/
int
ObjSetDouble
(
const
struct
vfp_ctx
*
v
c
,
enum
obj_attr
a
,
double
t
)
ObjSetDouble
(
struct
worker
*
wrk
,
struct
objcore
*
o
c
,
enum
obj_attr
a
,
double
t
)
{
void
*
vp
;
uint64_t
u
;
assert
(
sizeof
t
==
sizeof
u
);
memcpy
(
&
u
,
&
t
,
sizeof
u
);
vp
=
ObjSetattr
(
v
c
,
a
,
sizeof
u
,
NULL
);
vp
=
ObjSetattr
(
wrk
,
o
c
,
a
,
sizeof
u
,
NULL
);
if
(
vp
==
NULL
)
return
(
-
1
);
vbe64enc
(
vp
,
u
);
...
...
@@ -657,11 +657,11 @@ ObjGetDouble(struct worker *wrk, struct objcore *oc, enum obj_attr a, double *d)
*/
int
ObjSetU64
(
const
struct
vfp_ctx
*
v
c
,
enum
obj_attr
a
,
uint64_t
t
)
ObjSetU64
(
struct
worker
*
wrk
,
struct
objcore
*
o
c
,
enum
obj_attr
a
,
uint64_t
t
)
{
void
*
vp
;
vp
=
ObjSetattr
(
v
c
,
a
,
sizeof
t
,
NULL
);
vp
=
ObjSetattr
(
wrk
,
o
c
,
a
,
sizeof
t
,
NULL
);
if
(
vp
==
NULL
)
return
(
-
1
);
vbe64enc
(
vp
,
t
);
...
...
@@ -683,11 +683,11 @@ ObjGetU64(struct worker *wrk, struct objcore *oc, enum obj_attr a, uint64_t *d)
}
int
ObjSetU32
(
const
struct
vfp_ctx
*
v
c
,
enum
obj_attr
a
,
uint32_t
t
)
ObjSetU32
(
struct
worker
*
wrk
,
struct
objcore
*
o
c
,
enum
obj_attr
a
,
uint32_t
t
)
{
void
*
vp
;
vp
=
ObjSetattr
(
v
c
,
a
,
sizeof
t
,
NULL
);
vp
=
ObjSetattr
(
wrk
,
o
c
,
a
,
sizeof
t
,
NULL
);
if
(
vp
==
NULL
)
return
(
-
1
);
vbe32enc
(
vp
,
t
);
...
...
@@ -722,11 +722,11 @@ ObjCheckFlag(struct worker *wrk, struct objcore *oc, enum obj_flags of)
}
void
ObjSetFlag
(
const
struct
vfp_ctx
*
v
c
,
enum
obj_flags
of
,
int
val
)
ObjSetFlag
(
struct
worker
*
wrk
,
struct
objcore
*
o
c
,
enum
obj_flags
of
,
int
val
)
{
uint8_t
*
fp
;
fp
=
ObjSetattr
(
v
c
,
OA_FLAGS
,
1
,
NULL
);
fp
=
ObjSetattr
(
wrk
,
o
c
,
OA_FLAGS
,
1
,
NULL
);
AN
(
fp
);
if
(
val
)
(
*
fp
)
|=
of
;
...
...
bin/varnishd/storage/storage.h
View file @
58db58be
...
...
@@ -33,7 +33,6 @@
struct
stevedore
;
struct
sess
;
struct
dstat
;
struct
busyobj
;
struct
objcore
;
struct
worker
;
...
...
@@ -106,8 +105,8 @@ typedef void objtrimstore_f(struct worker *, struct objcore *);
typedef
void
objslim_f
(
struct
worker
*
,
struct
objcore
*
);
typedef
void
*
objgetattr_f
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
attr
,
ssize_t
*
len
);
typedef
void
*
objsetattr_f
(
const
struct
vfp_ctx
*
,
enum
obj_attr
attr
,
ssize_t
len
,
const
void
*
ptr
);
typedef
void
*
objsetattr_f
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
attr
,
ssize_t
len
,
const
void
*
ptr
);
typedef
uint64_t
objgetlen_f
(
struct
worker
*
,
struct
objcore
*
);
struct
storeobj_methods
{
...
...
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