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
4ded44b6
Commit
4ded44b6
authored
Feb 03, 2016
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make DYING a main Obj flag, add a function to set it (ObjKill)
and end random code mucking about with it.
parent
d2257489
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
17 deletions
+37
-17
cache.h
bin/varnishd/cache/cache.h
+2
-1
cache_expire.c
bin/varnishd/cache/cache_expire.c
+8
-11
cache_hash.c
bin/varnishd/cache/cache_hash.c
+5
-3
cache_obj.c
bin/varnishd/cache/cache_obj.c
+22
-2
No files found.
bin/varnishd/cache/cache.h
View file @
4ded44b6
...
...
@@ -427,12 +427,12 @@ struct objcore {
#define OC_F_ABANDON (1<<4)
#define OC_F_PRIVATE (1<<5)
#define OC_F_FAILED (1<<6)
#define OC_F_DYING (1<<7)
uint8_t
exp_flags
;
#define OC_EF_MOVE (1<<2)
#define OC_EF_INSERT (1<<3)
#define OC_EF_EXP (1<<4)
#define OC_EF_DYING (1<<5)
uint16_t
oa_present
;
...
...
@@ -858,6 +858,7 @@ void ObjWaitState(const struct objcore *, enum boc_state_e want);
void
ObjTrimStore
(
struct
worker
*
,
struct
objcore
*
);
void
ObjTouch
(
struct
worker
*
,
struct
objcore
*
,
double
now
);
int
ObjSnipe
(
const
struct
worker
*
,
struct
objcore
*
);
void
ObjKill
(
struct
objcore
*
);
unsigned
ObjGetXID
(
struct
worker
*
,
struct
objcore
*
);
uint64_t
ObjGetLen
(
struct
worker
*
,
struct
objcore
*
);
void
ObjUpdateMeta
(
struct
worker
*
,
struct
objcore
*
);
...
...
bin/varnishd/cache/cache_expire.c
View file @
4ded44b6
...
...
@@ -143,7 +143,7 @@ exp_mail_it(struct objcore *oc)
AN
(
oc
->
lru_flags
&
OC_LRU_OFFLRU
);
Lck_Lock
(
&
exphdl
->
mtx
);
if
(
oc
->
exp_flags
&
OC_E
F_DYING
)
if
(
oc
->
flags
&
OC_
F_DYING
)
VTAILQ_INSERT_HEAD
(
&
exphdl
->
inbox
,
oc
,
lru_list
);
else
VTAILQ_INSERT_TAIL
(
&
exphdl
->
inbox
,
oc
,
lru_list
);
...
...
@@ -168,7 +168,7 @@ EXP_Inject(struct worker *wrk, struct objcore *oc, struct lru *lru)
AZ
(
oc
->
lru_flags
&
OC_LRU_OFFLRU
);
AZ
(
oc
->
exp_flags
&
(
OC_EF_INSERT
|
OC_EF_MOVE
));
AZ
(
oc
->
exp_flags
&
OC_E
F_DYING
);
AZ
(
oc
->
flags
&
OC_
F_DYING
);
AZ
(
oc
->
flags
&
OC_F_BUSY
);
CHECK_OBJ_NOTNULL
(
lru
,
LRU_MAGIC
);
...
...
@@ -202,7 +202,7 @@ EXP_Insert(struct worker *wrk, struct objcore *oc)
AZ
(
oc
->
lru_flags
&
OC_LRU_OFFLRU
);
AZ
(
oc
->
exp_flags
&
(
OC_EF_INSERT
|
OC_EF_MOVE
));
AZ
(
oc
->
exp_flags
&
OC_E
F_DYING
);
AZ
(
oc
->
flags
&
OC_
F_DYING
);
AN
(
oc
->
flags
&
OC_F_BUSY
);
lru
=
ObjGetLRU
(
oc
);
...
...
@@ -256,15 +256,11 @@ EXP_Rearm(struct objcore *oc, double now, double ttl, double grace, double keep)
Lck_Lock
(
&
lru
->
mtx
);
if
(
!
isnan
(
now
)
&&
when
<=
now
)
oc
->
exp_flags
|=
OC_EF_DYING
;
else
oc
->
exp_flags
|=
OC_EF_MOVE
;
if
(
oc
->
lru_flags
&
OC_LRU_OFFLRU
)
{
oc
=
NULL
;
}
else
{
oc
->
lru_flags
|=
OC_LRU_OFFLRU
;
oc
->
exp_flags
|=
OC_EF_MOVE
;
VTAILQ_REMOVE
(
&
lru
->
lru_head
,
oc
,
lru_list
);
}
Lck_Unlock
(
&
lru
->
mtx
);
...
...
@@ -384,13 +380,13 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, double now)
AN
(
oc
->
lru_flags
&
OC_LRU_OFFLRU
);
oc
->
exp_flags
&=
~
(
OC_EF_INSERT
|
OC_EF_MOVE
);
oc
->
last_lru
=
now
;
if
(
!
(
flags
&
OC_E
F_DYING
))
{
if
(
!
(
oc
->
flags
&
OC_
F_DYING
))
{
VTAILQ_INSERT_TAIL
(
&
lru
->
lru_head
,
oc
,
lru_list
);
oc
->
lru_flags
&=
~
OC_LRU_OFFLRU
;
}
Lck_Unlock
(
&
lru
->
mtx
);
if
(
flags
&
OC_E
F_DYING
)
{
if
(
oc
->
flags
&
OC_
F_DYING
)
{
VSLb
(
&
ep
->
vsl
,
SLT_ExpKill
,
"EXP_Kill p=%p e=%.9f f=0x%x"
,
oc
,
oc
->
timer_when
,
oc
->
flags
);
if
(
!
(
flags
&
OC_EF_INSERT
))
{
...
...
@@ -458,7 +454,8 @@ exp_expire(struct exp_priv *ep, double now)
CHECK_OBJ_NOTNULL
(
lru
,
LRU_MAGIC
);
Lck_Lock
(
&
lru
->
mtx
);
oc
->
exp_flags
|=
OC_EF_DYING
;
if
(
!
(
oc
->
flags
&
OC_F_DYING
))
ObjKill
(
oc
);
if
(
oc
->
lru_flags
&
OC_LRU_OFFLRU
)
oc
=
NULL
;
else
{
...
...
bin/varnishd/cache/cache_hash.c
View file @
4ded44b6
...
...
@@ -393,7 +393,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
assert
(
oc
->
objhead
==
oh
);
if
(
oc
->
exp_flags
&
OC_E
F_DYING
)
if
(
oc
->
flags
&
OC_
F_DYING
)
continue
;
if
(
oc
->
flags
&
OC_F_FAILED
)
continue
;
...
...
@@ -415,8 +415,10 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
if
(
oc
->
exp
.
ttl
<=
0
.)
continue
;
if
(
BAN_CheckObject
(
wrk
,
oc
,
req
))
if
(
BAN_CheckObject
(
wrk
,
oc
,
req
))
{
oc
->
flags
|=
OC_F_DYING
;
continue
;
}
if
(
ObjHasAttr
(
wrk
,
oc
,
OA_VARY
))
{
vary
=
ObjGetAttr
(
wrk
,
oc
,
OA_VARY
,
NULL
);
...
...
@@ -585,7 +587,7 @@ double keep)
*/
continue
;
}
if
(
oc
->
exp_flags
&
OC_E
F_DYING
)
if
(
oc
->
flags
&
OC_
F_DYING
)
continue
;
if
(
spc
<
sizeof
*
ocp
)
{
/* Iterate if aws is not big enough */
...
...
bin/varnishd/cache/cache_obj.c
View file @
4ded44b6
...
...
@@ -369,6 +369,26 @@ ObjTouch(struct worker *wrk, struct objcore *oc, double now)
om
->
objtouch
(
wrk
,
oc
,
now
);
}
/*====================================================================
* ObjKill()
*
* It's dead Jim, kick it...
*/
void
ObjKill
(
struct
objcore
*
oc
)
{
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
CHECK_OBJ_NOTNULL
(
oc
->
objhead
,
OBJHEAD_MAGIC
);
AZ
(
oc
->
flags
&
OC_F_DYING
);
// XXX ?
Lck_Lock
(
&
oc
->
objhead
->
mtx
);
oc
->
flags
|=
OC_F_DYING
;
Lck_Unlock
(
&
oc
->
objhead
->
mtx
);
}
/*====================================================================
* ObjSnipe()
*
...
...
@@ -384,11 +404,11 @@ ObjSnipe(const struct worker *wrk, struct objcore *oc)
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
CHECK_OBJ_NOTNULL
(
oc
->
objhead
,
OBJHEAD_MAGIC
);
AZ
(
oc
->
exp_flags
&
OC_E
F_DYING
);
AZ
(
oc
->
flags
&
OC_
F_DYING
);
if
(
oc
->
refcnt
==
1
&&
!
Lck_Trylock
(
&
oc
->
objhead
->
mtx
))
{
if
(
oc
->
refcnt
==
1
)
{
oc
->
exp_flags
|=
OC_E
F_DYING
;
oc
->
flags
|=
OC_
F_DYING
;
oc
->
refcnt
++
;
retval
=
1
;
}
...
...
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