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
4ee1b911
Commit
4ee1b911
authored
Aug 11, 2014
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap the gzip/changed_gzip flags into a more general object flag
mechanism.
parent
ab53b55f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
14 deletions
+64
-14
cache.h
bin/varnishd/cache/cache.h
+11
-3
cache_esi_deliver.c
bin/varnishd/cache/cache_esi_deliver.c
+1
-1
cache_fetch.c
bin/varnishd/cache/cache_fetch.c
+5
-6
cache_http1_deliver.c
bin/varnishd/cache/cache_http1_deliver.c
+4
-2
cache_obj.c
bin/varnishd/cache/cache_obj.c
+32
-0
cache_req_fsm.c
bin/varnishd/cache/cache_req_fsm.c
+2
-1
obj_attr.h
include/tbl/obj_attr.h
+9
-1
No files found.
bin/varnishd/cache/cache.h
View file @
4ee1b911
...
...
@@ -553,6 +553,12 @@ enum obj_attr {
#undef OBJ_ATTR
};
enum
obj_flags
{
#define OBJ_FLAG(U, l, v) OF_##U = v,
#include "tbl/obj_attr.h"
#undef OBJ_FLAG
};
struct
object
{
unsigned
magic
;
#define OBJECT_MAGIC 0x32851d42
...
...
@@ -564,13 +570,12 @@ struct object {
uint8_t
*
oa_http
;
unsigned
gziped
:
1
;
u
nsigned
changed_gzip
:
1
;
u
int8_t
oa_flags
[
1
]
;
/* Bit positions in the gzip stream */
char
oa_gzipbits
[
24
];
/* VCL only variables */
char
oa_lastmodified
[
8
];
...
...
@@ -1077,6 +1082,9 @@ int ObjGetDouble(struct objcore *, struct dstat *, enum obj_attr, double *);
int
ObjGetU32
(
struct
objcore
*
,
struct
dstat
*
,
enum
obj_attr
,
uint32_t
*
);
int
ObjGetU64
(
struct
objcore
*
,
struct
dstat
*
,
enum
obj_attr
,
uint64_t
*
);
int
ObjCheckFlag
(
struct
objcore
*
oc
,
struct
dstat
*
ds
,
enum
obj_flags
of
);
void
ObjSetFlag
(
const
struct
vfp_ctx
*
vc
,
enum
obj_flags
of
,
int
val
);
/* cache_panic.c */
void
PAN_Init
(
void
);
const
char
*
body_status_2str
(
enum
body_status
e
);
...
...
bin/varnishd/cache/cache_esi_deliver.c
View file @
4ee1b911
...
...
@@ -516,7 +516,7 @@ ESI_DeliverChild(struct req *req)
obj
=
ObjGetObj
(
req
->
objcore
,
&
req
->
wrk
->
stats
);
CHECK_OBJ_NOTNULL
(
obj
,
OBJECT_MAGIC
);
if
(
!
obj
->
gziped
)
{
if
(
!
ObjCheckFlag
(
req
->
objcore
,
&
req
->
wrk
->
stats
,
OF_GZIPED
)
)
{
VTAILQ_FOREACH
(
st
,
&
obj
->
body
->
list
,
list
)
ved_pretend_gzip
(
req
,
st
->
ptr
,
st
->
len
);
return
;
...
...
bin/varnishd/cache/cache_fetch.c
View file @
4ee1b911
...
...
@@ -352,7 +352,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
if
(
bo
->
ims_obj
!=
NULL
&&
http_IsStatus
(
bo
->
beresp
,
304
))
{
http_Merge
(
bo
->
ims_obj
->
http
,
bo
->
beresp
,
bo
->
ims_obj
->
changed_gzip
);
ObjCheckFlag
(
bo
->
ims_oc
,
bo
->
stats
,
OF_CHGGZIP
)
);
assert
(
http_IsStatus
(
bo
->
beresp
,
200
));
do_ims
=
1
;
}
else
...
...
@@ -482,10 +482,10 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
bo
->
vfc
->
body
=
obj
->
body
;
if
(
bo
->
do_gzip
||
(
bo
->
is_gzip
&&
!
bo
->
do_gunzip
))
obj
->
gziped
=
1
;
ObjSetFlag
(
bo
->
vfc
,
OF_GZIPED
,
1
)
;
if
(
bo
->
do_gzip
||
bo
->
do_gunzip
)
obj
->
changed_gzip
=
1
;
ObjSetFlag
(
bo
->
vfc
,
OF_CHGGZIP
,
1
)
;
if
(
bo
->
htc
.
body_status
!=
BS_NONE
)
V1F_Setup_Fetch
(
bo
);
...
...
@@ -566,7 +566,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
if
(
bo
->
ims_obj
->
changed_gzip
)
{
if
(
ObjCheckFlag
(
bo
->
ims_oc
,
bo
->
stats
,
OF_CHGGZIP
)
)
{
/*
* If we modified the gzip status of the IMS object, that
* must control the C-E header, if any.
...
...
@@ -584,8 +584,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
if
(
ObjGetattr
(
bo
->
ims_oc
,
bo
->
stats
,
OA_ESIDATA
,
NULL
)
!=
NULL
)
AZ
(
ObjCopyAttr
(
bo
->
vfc
,
bo
->
ims_oc
,
OA_ESIDATA
));
obj
->
gziped
=
bo
->
ims_obj
->
gziped
;
AZ
(
ObjCopyAttr
(
bo
->
vfc
,
bo
->
ims_oc
,
OA_FLAGS
));
AZ
(
ObjCopyAttr
(
bo
->
vfc
,
bo
->
ims_oc
,
OA_GZIPBITS
));
AZ
(
WS_Overflowed
(
bo
->
ws_o
));
...
...
bin/varnishd/cache/cache_http1_deliver.c
View file @
4ee1b911
...
...
@@ -266,7 +266,8 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
req
->
res_mode
|=
RES_ESI_CHILD
;
}
if
(
cache_param
->
http_gzip_support
&&
req
->
obj
->
gziped
&&
if
(
cache_param
->
http_gzip_support
&&
ObjCheckFlag
(
req
->
objcore
,
&
req
->
wrk
->
stats
,
OF_GZIPED
)
&&
!
RFC2616_Req_Gzip
(
req
->
http
))
{
/*
* We don't know what it uncompresses to
...
...
@@ -344,7 +345,8 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
ESI_DeliverChild
(
req
);
}
else
if
(
req
->
res_mode
&
RES_GUNZIP
||
(
req
->
res_mode
&
RES_ESI_CHILD
&&
!
req
->
gzip_resp
&&
req
->
obj
->
gziped
))
{
!
req
->
gzip_resp
&&
ObjCheckFlag
(
req
->
objcore
,
&
req
->
wrk
->
stats
,
OF_GZIPED
)))
{
VDP_push
(
req
,
VDP_gunzip
);
req
->
vgz
=
VGZ_NewUngzip
(
req
->
vsl
,
"U D -"
);
AZ
(
VGZ_WrwInit
(
req
->
vgz
));
...
...
bin/varnishd/cache/cache_obj.c
View file @
4ee1b911
...
...
@@ -232,6 +232,9 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr,
return
(
NULL
);
*
len
=
o
->
esidata
->
len
;
return
(
o
->
esidata
->
ptr
);
case
OA_FLAGS
:
*
len
=
sizeof
o
->
oa_flags
;
return
(
o
->
oa_flags
);
case
OA_GZIPBITS
:
*
len
=
sizeof
o
->
oa_gzipbits
;
return
(
o
->
oa_gzipbits
);
...
...
@@ -271,6 +274,9 @@ ObjSetattr(const struct vfp_ctx *vc, enum obj_attr attr,
return
(
NULL
);
o
->
esidata
->
len
=
len
;
return
(
o
->
esidata
->
ptr
);
case
OA_FLAGS
:
assert
(
len
==
sizeof
o
->
oa_flags
);
return
(
o
->
oa_flags
);
case
OA_GZIPBITS
:
assert
(
len
==
sizeof
o
->
oa_gzipbits
);
return
(
o
->
oa_gzipbits
);
...
...
@@ -420,3 +426,29 @@ ObjGetU32(struct objcore *oc, struct dstat *ds, enum obj_attr a, uint32_t *d)
*
d
=
vbe32dec
(
vp
);
return
(
0
);
}
/*--------------------------------------------------------------------
*/
int
ObjCheckFlag
(
struct
objcore
*
oc
,
struct
dstat
*
ds
,
enum
obj_flags
of
)
{
uint8_t
*
fp
;
fp
=
ObjGetattr
(
oc
,
ds
,
OA_FLAGS
,
NULL
);
AN
(
fp
);
return
((
*
fp
)
&
of
);
}
void
ObjSetFlag
(
const
struct
vfp_ctx
*
vc
,
enum
obj_flags
of
,
int
val
)
{
uint8_t
*
fp
;
fp
=
ObjSetattr
(
vc
,
OA_FLAGS
,
1
);
AN
(
fp
);
if
(
val
)
(
*
fp
)
|=
of
;
else
(
*
fp
)
&=
~
of
;
}
bin/varnishd/cache/cache_req_fsm.c
View file @
4ee1b911
...
...
@@ -128,7 +128,8 @@ cnt_deliver(struct worker *wrk, struct req *req)
http_SetHeader
(
req
->
resp
,
"Via: 1.1 varnish-v4"
);
if
(
cache_param
->
http_gzip_support
&&
req
->
obj
->
gziped
&&
if
(
cache_param
->
http_gzip_support
&&
ObjCheckFlag
(
req
->
objcore
,
&
req
->
wrk
->
stats
,
OF_GZIPED
)
&&
!
RFC2616_Req_Gzip
(
req
->
http
))
RFC2616_Weaken_Etag
(
req
->
resp
);
...
...
include/tbl/obj_attr.h
View file @
4ee1b911
...
...
@@ -30,13 +30,21 @@
/*lint -save -e525 -e539 */
/* upper, lower */
#ifdef OBJ_ATTR
OBJ_ATTR
(
VXID
,
vxid
)
OBJ_ATTR
(
EXP
,
exp
)
OBJ_ATTR
(
VARY
,
vary
)
OBJ_ATTR
(
HEADERS
,
headers
)
OBJ_ATTR
(
GZIPFLAGS
,
gzip
flags
)
OBJ_ATTR
(
FLAGS
,
flags
)
OBJ_ATTR
(
GZIPBITS
,
gzipbits
)
OBJ_ATTR
(
ESIDATA
,
esidata
)
OBJ_ATTR
(
LASTMODIFIED
,
lastmodified
)
#endif
#ifdef OBJ_FLAG
/* upper, lower, val */
OBJ_FLAG
(
GZIPED
,
gziped
,
(
1
<<
1
))
OBJ_FLAG
(
CHGGZIP
,
chggzip
,
(
1
<<
2
))
#endif
/*lint -restore */
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