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
7375e05e
Commit
7375e05e
authored
Feb 08, 2016
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wean cache_rfc2616.c from struct exp.
parent
6aca2141
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
26 deletions
+33
-26
cache.h
bin/varnishd/cache/cache.h
+2
-1
cache_fetch.c
bin/varnishd/cache/cache_fetch.c
+6
-2
cache_rfc2616.c
bin/varnishd/cache/cache_rfc2616.c
+25
-23
No files found.
bin/varnishd/cache/cache.h
View file @
7375e05e
...
@@ -1050,7 +1050,8 @@ int WS_Overflowed(const struct ws *ws);
...
@@ -1050,7 +1050,8 @@ int WS_Overflowed(const struct ws *ws);
void
*
WS_Printf
(
struct
ws
*
ws
,
const
char
*
fmt
,
...)
__v_printflike
(
2
,
3
);
void
*
WS_Printf
(
struct
ws
*
ws
,
const
char
*
fmt
,
...)
__v_printflike
(
2
,
3
);
/* cache_rfc2616.c */
/* cache_rfc2616.c */
void
RFC2616_Ttl
(
struct
busyobj
*
,
double
now
);
void
RFC2616_Ttl
(
struct
busyobj
*
,
double
now
,
double
*
t_origin
,
float
*
ttl
,
float
*
grace
,
float
*
keep
);
unsigned
RFC2616_Req_Gzip
(
const
struct
http
*
);
unsigned
RFC2616_Req_Gzip
(
const
struct
http
*
);
int
RFC2616_Do_Cond
(
const
struct
req
*
sp
);
int
RFC2616_Do_Cond
(
const
struct
req
*
sp
);
void
RFC2616_Weaken_Etag
(
struct
http
*
hp
);
void
RFC2616_Weaken_Etag
(
struct
http
*
hp
);
...
...
bin/varnishd/cache/cache_fetch.c
View file @
7375e05e
...
@@ -384,8 +384,12 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
...
@@ -384,8 +384,12 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
/*
/*
* What does RFC2616 think about TTL ?
* What does RFC2616 think about TTL ?
*/
*/
EXP_Clr
(
&
bo
->
fetch_objcore
->
exp
);
RFC2616_Ttl
(
bo
,
now
,
RFC2616_Ttl
(
bo
,
now
);
&
bo
->
fetch_objcore
->
exp
.
t_origin
,
&
bo
->
fetch_objcore
->
exp
.
ttl
,
&
bo
->
fetch_objcore
->
exp
.
grace
,
&
bo
->
fetch_objcore
->
exp
.
keep
);
/* private objects have negative TTL */
/* private objects have negative TTL */
if
(
bo
->
fetch_objcore
->
flags
&
OC_F_PRIVATE
)
if
(
bo
->
fetch_objcore
->
flags
&
OC_F_PRIVATE
)
...
...
bin/varnishd/cache/cache_rfc2616.c
View file @
7375e05e
...
@@ -62,25 +62,27 @@
...
@@ -62,25 +62,27 @@
*/
*/
void
void
RFC2616_Ttl
(
struct
busyobj
*
bo
,
double
now
)
RFC2616_Ttl
(
struct
busyobj
*
bo
,
double
now
,
double
*
t_origin
,
float
*
ttl
,
float
*
grace
,
float
*
keep
)
{
{
unsigned
max_age
,
age
;
unsigned
max_age
,
age
;
double
h_date
,
h_expires
;
double
h_date
,
h_expires
;
const
char
*
p
;
const
char
*
p
;
const
struct
http
*
hp
;
const
struct
http
*
hp
;
struct
exp
*
expp
;
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
expp
=
&
bo
->
fetch_objcore
->
exp
;
hp
=
bo
->
beresp
;
assert
(
now
!=
0
.
0
&&
!
isnan
(
now
));
assert
(
now
!=
0
.
0
&&
!
isnan
(
now
));
expp
->
t_origin
=
now
;
AN
(
t_origin
);
AN
(
ttl
);
AN
(
grace
);
AN
(
keep
);
expp
->
ttl
=
cache_param
->
default_ttl
;
*
t_origin
=
now
;
expp
->
grace
=
cache_param
->
default_grace
;
*
ttl
=
cache_param
->
default_ttl
;
expp
->
keep
=
cache_param
->
default_keep
;
*
grace
=
cache_param
->
default_grace
;
*
keep
=
cache_param
->
default_keep
;
hp
=
bo
->
beresp
;
max_age
=
age
=
0
;
max_age
=
age
=
0
;
h_expires
=
0
;
h_expires
=
0
;
...
@@ -98,7 +100,7 @@ RFC2616_Ttl(struct busyobj *bo, double now)
...
@@ -98,7 +100,7 @@ RFC2616_Ttl(struct busyobj *bo, double now)
* compatible with fractional seconds.
* compatible with fractional seconds.
*/
*/
age
=
strtoul
(
p
,
NULL
,
10
);
age
=
strtoul
(
p
,
NULL
,
10
);
expp
->
t_origin
-=
age
;
*
t_origin
-=
age
;
}
}
if
(
http_GetHdr
(
hp
,
H_Expires
,
&
p
))
if
(
http_GetHdr
(
hp
,
H_Expires
,
&
p
))
...
@@ -109,7 +111,7 @@ RFC2616_Ttl(struct busyobj *bo, double now)
...
@@ -109,7 +111,7 @@ RFC2616_Ttl(struct busyobj *bo, double now)
switch
(
http_GetStatus
(
hp
))
{
switch
(
http_GetStatus
(
hp
))
{
default:
default:
expp
->
ttl
=
-
1
.;
*
ttl
=
-
1
.;
break
;
break
;
case
302
:
/* Moved Temporarily */
case
302
:
/* Moved Temporarily */
case
307
:
/* Temporary Redirect */
case
307
:
/* Temporary Redirect */
...
@@ -119,7 +121,7 @@ RFC2616_Ttl(struct busyobj *bo, double now)
...
@@ -119,7 +121,7 @@ RFC2616_Ttl(struct busyobj *bo, double now)
* Do not apply the default ttl, only set a ttl if Cache-Control
* Do not apply the default ttl, only set a ttl if Cache-Control
* or Expires are present. Uncacheable otherwise.
* or Expires are present. Uncacheable otherwise.
*/
*/
expp
->
ttl
=
-
1
.;
*
ttl
=
-
1
.;
/* FALL-THROUGH */
/* FALL-THROUGH */
case
200
:
/* OK */
case
200
:
/* OK */
case
203
:
/* Non-Authoritative Information */
case
203
:
/* Non-Authoritative Information */
...
@@ -144,7 +146,7 @@ RFC2616_Ttl(struct busyobj *bo, double now)
...
@@ -144,7 +146,7 @@ RFC2616_Ttl(struct busyobj *bo, double now)
else
else
max_age
=
strtoul
(
p
,
NULL
,
0
);
max_age
=
strtoul
(
p
,
NULL
,
0
);
expp
->
ttl
=
max_age
;
*
ttl
=
max_age
;
break
;
break
;
}
}
...
@@ -155,7 +157,7 @@ RFC2616_Ttl(struct busyobj *bo, double now)
...
@@ -155,7 +157,7 @@ RFC2616_Ttl(struct busyobj *bo, double now)
/* If backend told us it is expired already, don't cache. */
/* If backend told us it is expired already, don't cache. */
if
(
h_expires
<
h_date
)
{
if
(
h_expires
<
h_date
)
{
expp
->
ttl
=
0
;
*
ttl
=
0
;
break
;
break
;
}
}
...
@@ -167,9 +169,9 @@ RFC2616_Ttl(struct busyobj *bo, double now)
...
@@ -167,9 +169,9 @@ RFC2616_Ttl(struct busyobj *bo, double now)
* trust Expires: relative to our own clock.
* trust Expires: relative to our own clock.
*/
*/
if
(
h_expires
<
now
)
if
(
h_expires
<
now
)
expp
->
ttl
=
0
;
*
ttl
=
0
;
else
else
expp
->
ttl
=
h_expires
-
now
;
*
ttl
=
h_expires
-
now
;
break
;
break
;
}
else
{
}
else
{
/*
/*
...
@@ -177,7 +179,7 @@ RFC2616_Ttl(struct busyobj *bo, double now)
...
@@ -177,7 +179,7 @@ RFC2616_Ttl(struct busyobj *bo, double now)
* derive a relative time from the two headers.
* derive a relative time from the two headers.
* (the negative ttl case is caught above)
* (the negative ttl case is caught above)
*/
*/
expp
->
ttl
=
(
int
)(
h_expires
-
h_date
);
*
ttl
=
(
int
)(
h_expires
-
h_date
);
}
}
}
}
...
@@ -186,19 +188,19 @@ RFC2616_Ttl(struct busyobj *bo, double now)
...
@@ -186,19 +188,19 @@ RFC2616_Ttl(struct busyobj *bo, double now)
* RFC5861 outlines a way to control the use of stale responses.
* RFC5861 outlines a way to control the use of stale responses.
* We use this to initialize the grace period.
* We use this to initialize the grace period.
*/
*/
if
(
expp
->
ttl
>=
0
&&
http_GetHdrField
(
hp
,
H_Cache_Control
,
if
(
*
ttl
>=
0
&&
http_GetHdrField
(
hp
,
H_Cache_Control
,
"stale-while-revalidate"
,
&
p
)
&&
p
!=
NULL
)
{
"stale-while-revalidate"
,
&
p
)
&&
p
!=
NULL
)
{
if
(
*
p
==
'-'
)
if
(
*
p
==
'-'
)
expp
->
grace
=
0
;
*
grace
=
0
;
else
else
expp
->
grace
=
strtoul
(
p
,
NULL
,
0
);
*
grace
=
strtoul
(
p
,
NULL
,
0
);
}
}
VSLb
(
bo
->
vsl
,
SLT_TTL
,
VSLb
(
bo
->
vsl
,
SLT_TTL
,
"RFC %.0f %.0f %.0f %.0f %.0f %.0f %.0f %u"
,
"RFC %.0f %.0f %.0f %.0f %.0f %.0f %.0f %u"
,
expp
->
ttl
,
expp
->
grace
,
-
1
.,
now
,
*
ttl
,
*
grace
,
-
1
.,
now
,
expp
->
t_origin
,
h_date
,
h_expires
,
max_age
);
*
t_origin
,
h_date
,
h_expires
,
max_age
);
}
}
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
...
...
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