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
7264c919
Commit
7264c919
authored
Mar 02, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move grace and ttl variables into a common structure and rename
HSH_Grace() to EXP_Grace()
parent
72d94d7c
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
62 additions
and
57 deletions
+62
-57
cache.h
bin/varnishd/cache.h
+11
-5
cache_ban.c
bin/varnishd/cache_ban.c
+3
-3
cache_center.c
bin/varnishd/cache_center.c
+8
-8
cache_expire.c
bin/varnishd/cache_expire.c
+9
-1
cache_hash.c
bin/varnishd/cache_hash.c
+9
-17
cache_session.c
bin/varnishd/cache_session.c
+1
-1
cache_vrt_var.c
bin/varnishd/cache_vrt_var.c
+12
-12
hash_slinger.h
bin/varnishd/hash_slinger.h
+0
-1
stevedore.c
bin/varnishd/stevedore.c
+2
-2
storage_persistent.c
bin/varnishd/storage_persistent.c
+2
-2
storage_persistent_silo.c
bin/varnishd/storage_persistent_silo.c
+5
-5
No files found.
bin/varnishd/cache.h
View file @
7264c919
...
...
@@ -232,6 +232,13 @@ extern struct vfp vfp_esi;
/*--------------------------------------------------------------------*/
struct
exp
{
double
ttl
;
double
grace
;
};
/*--------------------------------------------------------------------*/
struct
worker
{
unsigned
magic
;
#define WORKER_MAGIC 0x6391adcf
...
...
@@ -272,8 +279,7 @@ struct worker {
double
age
;
double
entered
;
double
ttl
;
double
grace
;
struct
exp
exp
;
/* This is only here so VRT can find it */
const
char
*
storage_hint
;
...
...
@@ -449,10 +455,9 @@ struct object {
ssize_t
len
;
double
ttl
;
double
age
;
double
entered
;
double
grace
;
struct
exp
exp
;
double
last_modified
;
double
last_lru
;
...
...
@@ -517,7 +522,7 @@ struct sess {
double
t_end
;
/* Acceptable grace period */
double
grace
;
struct
exp
exp
;
enum
step
step
;
unsigned
cur_method
;
...
...
@@ -628,6 +633,7 @@ extern pthread_t cli_thread;
#define ASSERT_CLI() do {assert(pthread_self() == cli_thread);} while (0)
/* cache_expiry.c */
double
EXP_Grace
(
double
g
);
void
EXP_Insert
(
struct
object
*
o
);
void
EXP_Inject
(
struct
objcore
*
oc
,
struct
lru
*
lru
,
double
when
);
void
EXP_Init
(
void
);
...
...
bin/varnishd/cache_ban.c
View file @
7264c919
...
...
@@ -475,8 +475,8 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req)
oc_updatemeta
(
oc
);
return
(
0
);
}
else
{
o
->
ttl
=
0
;
o
->
grace
=
0
;
o
->
exp
.
ttl
=
0
;
o
->
exp
.
grace
=
0
;
oc
->
ban
=
NULL
;
oc_updatemeta
(
oc
);
/* BAN also changed, but that is not important any more */
...
...
@@ -543,7 +543,7 @@ ban_lurker(struct sess *sp, void *priv)
// AZ(oc->flags & OC_F_PERSISTENT);
o
=
oc_getobj
(
sp
->
wrk
,
oc
);
i
=
ban_check_object
(
o
,
sp
,
0
);
WSP
(
sp
,
SLT_Debug
,
"lurker: %p %g %d"
,
oc
,
o
->
ttl
,
i
);
WSP
(
sp
,
SLT_Debug
,
"lurker: %p %g %d"
,
oc
,
o
->
exp
.
ttl
,
i
);
(
void
)
HSH_Deref
(
sp
->
wrk
,
NULL
,
&
o
);
TIM_sleep
(
params
->
ban_lurker_sleep
);
}
...
...
bin/varnishd/cache_center.c
View file @
7264c919
...
...
@@ -527,7 +527,7 @@ cnt_fetch(struct sess *sp)
*/
sp
->
wrk
->
entered
=
TIM_real
();
sp
->
wrk
->
age
=
0
;
sp
->
wrk
->
ttl
=
RFC2616_Ttl
(
sp
);
sp
->
wrk
->
exp
.
ttl
=
RFC2616_Ttl
(
sp
);
/*
* Initial cacheability determination per [RFC2616, 13.4]
...
...
@@ -543,16 +543,16 @@ cnt_fetch(struct sess *sp)
case
404
:
/* Not Found */
break
;
default:
sp
->
wrk
->
ttl
=
sp
->
t_req
-
1
.;
sp
->
wrk
->
exp
.
ttl
=
sp
->
t_req
-
1
.;
break
;
}
/* pass from vclrecv{} has negative TTL */
if
(
sp
->
objcore
==
NULL
)
sp
->
wrk
->
ttl
=
sp
->
t_req
-
1
.;
sp
->
wrk
->
exp
.
ttl
=
sp
->
t_req
-
1
.;
sp
->
wrk
->
do_esi
=
0
;
sp
->
wrk
->
grace
=
NAN
;
sp
->
wrk
->
exp
.
grace
=
NAN
;
sp
->
wrk
->
body_status
=
RFC2616_Body
(
sp
);
...
...
@@ -564,7 +564,7 @@ cnt_fetch(struct sess *sp)
/* This is a pass from vcl_recv */
pass
=
1
;
/* VCL may have fiddled this, but that doesn't help */
sp
->
wrk
->
ttl
=
sp
->
t_req
-
1
.;
sp
->
wrk
->
exp
.
ttl
=
sp
->
t_req
-
1
.;
}
else
if
(
sp
->
handling
==
VCL_RET_HIT_FOR_PASS
)
{
/* pass from vcl_fetch{} -> hit-for-pass */
/* XXX: the bereq was not filtered pass... */
...
...
@@ -653,12 +653,12 @@ cnt_fetch(struct sess *sp)
*/
l
+=
strlen
(
"Content-Length: XxxXxxXxxXxxXxxXxx"
)
+
sizeof
(
void
*
);
if
(
sp
->
wrk
->
ttl
<
sp
->
t_req
+
params
->
shortlived
||
if
(
sp
->
wrk
->
exp
.
ttl
<
sp
->
t_req
+
params
->
shortlived
||
sp
->
objcore
==
NULL
)
sp
->
wrk
->
storage_hint
=
TRANSIENT_STORAGE
;
sp
->
obj
=
STV_NewObject
(
sp
,
sp
->
wrk
->
storage_hint
,
l
,
sp
->
wrk
->
ttl
,
nhttp
);
sp
->
wrk
->
exp
.
ttl
,
nhttp
);
/* XXX: -> 513 */
CHECK_OBJ_NOTNULL
(
sp
->
obj
,
OBJECT_MAGIC
);
...
...
@@ -678,7 +678,7 @@ cnt_fetch(struct sess *sp)
sp
->
obj
->
xid
=
sp
->
xid
;
sp
->
obj
->
response
=
sp
->
err_code
;
sp
->
obj
->
grace
=
sp
->
wrk
->
grace
;
sp
->
obj
->
exp
.
grace
=
sp
->
wrk
->
exp
.
grace
;
sp
->
obj
->
age
=
sp
->
wrk
->
age
;
sp
->
obj
->
entered
=
sp
->
wrk
->
entered
;
WS_Assert
(
sp
->
obj
->
ws_o
);
...
...
bin/varnishd/cache_expire.c
View file @
7264c919
...
...
@@ -57,6 +57,14 @@ static pthread_t exp_thread;
static
struct
binheap
*
exp_heap
;
static
struct
lock
exp_mtx
;
double
EXP_Grace
(
double
g
)
{
if
(
isnan
(
g
))
return
(
double
)(
params
->
default_grace
);
return
(
g
);
}
/*--------------------------------------------------------------------
* When & why does the timer fire for this object ?
*/
...
...
@@ -72,7 +80,7 @@ update_object_when(const struct object *o)
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
Lck_AssertHeld
(
&
exp_mtx
);
when
=
o
->
ttl
+
HSH_Grace
(
o
->
grace
);
when
=
o
->
exp
.
ttl
+
EXP_Grace
(
o
->
exp
.
grace
);
assert
(
!
isnan
(
when
));
if
(
when
==
oc
->
timer_when
)
return
(
0
);
...
...
bin/varnishd/cache_hash.c
View file @
7264c919
...
...
@@ -72,14 +72,6 @@ SVNID("$Id$")
static
const
struct
hash_slinger
*
hash
;
/*---------------------------------------------------------------------*/
double
HSH_Grace
(
double
g
)
{
if
(
isnan
(
g
))
return
(
double
)(
params
->
default_grace
);
return
(
g
);
}
/* Precreate an objhead and object for later use */
void
HSH_Prealloc
(
const
struct
sess
*
sp
)
...
...
@@ -362,7 +354,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
o
=
oc_getobj
(
sp
->
wrk
,
oc
);
CHECK_OBJ_NOTNULL
(
o
,
OBJECT_MAGIC
);
if
(
o
->
ttl
==
0
)
if
(
o
->
exp
.
ttl
==
0
)
continue
;
if
(
BAN_CheckObject
(
o
,
sp
))
continue
;
...
...
@@ -370,17 +362,17 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
continue
;
/* If still valid, use it */
if
(
o
->
ttl
>=
sp
->
t_req
)
if
(
o
->
exp
.
ttl
>=
sp
->
t_req
)
break
;
/*
* Remember any matching objects inside their grace period
* and if there are several, use the least expired one.
*/
if
(
o
->
ttl
+
HSH_Grace
(
o
->
grace
)
>=
sp
->
t_req
)
{
if
(
grace_oc
==
NULL
||
grace_ttl
<
o
->
ttl
)
{
if
(
o
->
exp
.
ttl
+
EXP_Grace
(
o
->
exp
.
grace
)
>=
sp
->
t_req
)
{
if
(
grace_oc
==
NULL
||
grace_ttl
<
o
->
exp
.
ttl
)
{
grace_oc
=
oc
;
grace_ttl
=
o
->
ttl
;
grace_ttl
=
o
->
exp
.
ttl
;
}
}
}
...
...
@@ -404,7 +396,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
/* Or it is impossible to fetch */
o
=
oc_getobj
(
sp
->
wrk
,
grace_oc
);
CHECK_OBJ_NOTNULL
(
o
,
OBJECT_MAGIC
);
if
(
o
->
ttl
+
HSH_Grace
(
sp
->
grace
)
>=
sp
->
t_req
)
if
(
o
->
exp
.
ttl
+
EXP_Grace
(
sp
->
exp
.
grace
)
>=
sp
->
t_req
)
oc
=
grace_oc
;
}
sp
->
objcore
=
NULL
;
...
...
@@ -552,9 +544,9 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace)
if
(
o
==
NULL
)
continue
;
CHECK_OBJ_NOTNULL
(
o
,
OBJECT_MAGIC
);
o
->
ttl
=
sp
->
t_req
+
ttl
;
o
->
exp
.
ttl
=
sp
->
t_req
+
ttl
;
if
(
!
isnan
(
grace
))
o
->
grace
=
grace
;
o
->
exp
.
grace
=
grace
;
EXP_Rearm
(
o
);
(
void
)
HSH_Deref
(
sp
->
wrk
,
NULL
,
&
o
);
}
...
...
@@ -577,7 +569,7 @@ HSH_Drop(struct sess *sp)
o
=
sp
->
obj
;
CHECK_OBJ_NOTNULL
(
o
,
OBJECT_MAGIC
);
AssertObjPassOrBusy
(
o
);
o
->
ttl
=
0
;
o
->
exp
.
ttl
=
0
;
if
(
o
->
objcore
!=
NULL
)
/* Pass has no objcore */
HSH_Unbusy
(
sp
);
(
void
)
HSH_Deref
(
sp
->
wrk
,
NULL
,
&
sp
->
obj
);
...
...
bin/varnishd/cache_session.c
View file @
7264c919
...
...
@@ -174,7 +174,7 @@ ses_setup(struct sessmem *sm)
sp
->
t_req
=
NAN
;
sp
->
t_resp
=
NAN
;
sp
->
t_end
=
NAN
;
sp
->
grace
=
NAN
;
sp
->
exp
.
grace
=
NAN
;
WS_Init
(
sp
->
ws
,
"sess"
,
sm
->
wsp
,
sm
->
workspace
);
sp
->
http
=
sm
->
http
[
0
];
...
...
bin/varnishd/cache_vrt_var.c
View file @
7264c919
...
...
@@ -247,17 +247,17 @@ VRT_l_beresp_ttl(const struct sess *sp, double a)
* We special case and make sure that rounding does not surprise.
*/
if
(
a
<=
0
)
{
sp
->
wrk
->
ttl
=
sp
->
t_req
-
1
;
sp
->
wrk
->
grace
=
0
.;
sp
->
wrk
->
exp
.
ttl
=
sp
->
t_req
-
1
;
sp
->
wrk
->
exp
.
grace
=
0
.;
}
else
sp
->
wrk
->
ttl
=
sp
->
t_req
+
a
;
sp
->
wrk
->
exp
.
ttl
=
sp
->
t_req
+
a
;
}
double
VRT_r_beresp_ttl
(
const
struct
sess
*
sp
)
{
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
return
(
sp
->
wrk
->
ttl
-
sp
->
t_req
);
return
(
sp
->
wrk
->
exp
.
ttl
-
sp
->
t_req
);
}
/*--------------------------------------------------------------------*/
...
...
@@ -351,10 +351,10 @@ VRT_l_obj_ttl(const struct sess *sp, double a)
* We special case and make sure that rounding does not surprise.
*/
if
(
a
<=
0
)
{
sp
->
obj
->
ttl
=
sp
->
t_req
-
1
;
sp
->
obj
->
grace
=
0
;
sp
->
obj
->
exp
.
ttl
=
sp
->
t_req
-
1
;
sp
->
obj
->
exp
.
grace
=
0
;
}
else
sp
->
obj
->
ttl
=
sp
->
t_req
+
a
;
sp
->
obj
->
exp
.
ttl
=
sp
->
t_req
+
a
;
EXP_Rearm
(
sp
->
obj
);
}
...
...
@@ -365,7 +365,7 @@ VRT_r_obj_ttl(const struct sess *sp)
CHECK_OBJ_NOTNULL
(
sp
->
obj
,
OBJECT_MAGIC
);
/* XXX */
if
(
sp
->
obj
->
objcore
==
NULL
)
return
(
0
.
0
);
return
(
sp
->
obj
->
ttl
-
sp
->
t_req
);
return
(
sp
->
obj
->
exp
.
ttl
-
sp
->
t_req
);
}
/*--------------------------------------------------------------------*/
...
...
@@ -451,12 +451,12 @@ VRT_r_##which##_grace(struct sess *sp) \
{ \
\
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \
return(
HSH
_Grace(fld)); \
return(
EXP
_Grace(fld)); \
}
VRT_DO_GRACE
(
req
,
sp
->
grace
,
)
VRT_DO_GRACE
(
obj
,
sp
->
obj
->
grace
,
EXP_Rearm
(
sp
->
obj
))
VRT_DO_GRACE
(
beresp
,
sp
->
wrk
->
grace
,
)
VRT_DO_GRACE
(
req
,
sp
->
exp
.
grace
,
)
VRT_DO_GRACE
(
obj
,
sp
->
obj
->
exp
.
grace
,
EXP_Rearm
(
sp
->
obj
))
VRT_DO_GRACE
(
beresp
,
sp
->
wrk
->
exp
.
grace
,
)
/*--------------------------------------------------------------------
* req.xid
...
...
bin/varnishd/hash_slinger.h
View file @
7264c919
...
...
@@ -58,7 +58,6 @@ struct objcore *HSH_Lookup(struct sess *sp, struct objhead **poh);
void
HSH_Unbusy
(
const
struct
sess
*
sp
);
void
HSH_Ref
(
struct
objcore
*
o
);
void
HSH_Drop
(
struct
sess
*
sp
);
double
HSH_Grace
(
double
g
);
void
HSH_Init
(
void
);
void
HSH_AddString
(
const
struct
sess
*
sp
,
const
char
*
str
);
void
HSH_FindBan
(
const
struct
sess
*
sp
,
struct
objcore
**
oc
);
...
...
bin/varnishd/stevedore.c
View file @
7264c919
...
...
@@ -198,9 +198,9 @@ STV_MkObject(struct sess *sp, void *ptr, unsigned ltot,
http_Setup
(
o
->
http
,
o
->
ws_o
);
o
->
http
->
magic
=
HTTP_MAGIC
;
o
->
grace
=
NAN
;
o
->
exp
.
grace
=
NAN
;
o
->
entered
=
NAN
;
o
->
ttl
=
soc
->
ttl
;
o
->
exp
.
ttl
=
soc
->
ttl
;
VTAILQ_INIT
(
&
o
->
store
);
sp
->
wrk
->
stats
.
n_object
++
;
...
...
bin/varnishd/storage_persistent.c
View file @
7264c919
...
...
@@ -493,7 +493,7 @@ smp_allocobj(struct stevedore *stv, struct sess *sp, unsigned ltot,
CAST_OBJ_NOTNULL
(
sc
,
stv
->
priv
,
SMP_SC_MAGIC
);
AN
(
sp
->
objcore
);
AN
(
sp
->
wrk
->
ttl
>=
0
);
AN
(
sp
->
wrk
->
exp
.
ttl
>=
0
);
ltot
=
IRNUP
(
sc
,
ltot
);
...
...
@@ -519,7 +519,7 @@ smp_allocobj(struct stevedore *stv, struct sess *sp, unsigned ltot,
/* We have to do this somewhere, might as well be here... */
assert
(
sizeof
so
->
hash
==
DIGEST_LEN
);
memcpy
(
so
->
hash
,
oc
->
objhead
->
digest
,
DIGEST_LEN
);
so
->
ttl
=
o
->
ttl
;
/* XXX: grace? */
so
->
ttl
=
o
->
exp
.
ttl
;
/* XXX: grace? */
so
->
ptr
=
(
uint8_t
*
)
o
-
sc
->
base
;
so
->
ban
=
o
->
ban_t
;
...
...
bin/varnishd/storage_persistent_silo.c
View file @
7264c919
...
...
@@ -433,8 +433,8 @@ smp_oc_getobj(struct worker *wrk, struct objcore *oc)
bad
|=
0x100
;
if
(
bad
)
{
o
->
ttl
=
0
;
o
->
grace
=
0
;
o
->
exp
.
ttl
=
0
;
o
->
exp
.
grace
=
0
;
so
->
ttl
=
0
;
}
...
...
@@ -463,10 +463,10 @@ smp_oc_updatemeta(struct objcore *oc)
CHECK_OBJ_NOTNULL
(
sg
->
sc
,
SMP_SC_MAGIC
);
so
=
smp_find_so
(
sg
,
oc
);
if
(
isnan
(
o
->
grace
))
mttl
=
o
->
ttl
;
if
(
isnan
(
o
->
exp
.
grace
))
mttl
=
o
->
exp
.
ttl
;
else
mttl
=
-
(
o
->
ttl
+
o
->
grace
);
mttl
=
-
(
o
->
exp
.
ttl
+
o
->
exp
.
grace
);
if
(
sg
==
sg
->
sc
->
cur_seg
)
{
/* Lock necessary, we might race close_seg */
...
...
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