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
f2882d3c
Commit
f2882d3c
authored
Feb 03, 2016
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ObjKill() for sniping an objcore, for instance for LRU-kills.
parent
c1ee4c9f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
26 deletions
+37
-26
cache.h
bin/varnishd/cache/cache.h
+5
-4
cache_expire.c
bin/varnishd/cache/cache_expire.c
+3
-22
cache_obj.c
bin/varnishd/cache/cache_obj.c
+29
-0
No files found.
bin/varnishd/cache/cache.h
View file @
f2882d3c
...
...
@@ -855,12 +855,13 @@ ssize_t ObjWaitExtend(struct worker *, struct objcore *, ssize_t l);
void
ObjSetState
(
const
struct
objcore
*
,
enum
boc_state_e
next
);
void
ObjWaitState
(
const
struct
objcore
*
,
enum
boc_state_e
want
);
void
ObjTrimStore
(
struct
worker
*
,
struct
objcore
*
);
void
ObjTouch
(
struct
worker
*
wrk
,
struct
objcore
*
oc
,
double
now
);
void
ObjTouch
(
struct
worker
*
,
struct
objcore
*
,
double
now
);
int
ObjKill
(
const
struct
worker
*
,
struct
objcore
*
);
unsigned
ObjGetXID
(
struct
worker
*
,
struct
objcore
*
);
uint64_t
ObjGetLen
(
struct
worker
*
,
struct
objcore
*
oc
);
uint64_t
ObjGetLen
(
struct
worker
*
,
struct
objcore
*
);
void
ObjUpdateMeta
(
struct
worker
*
,
struct
objcore
*
);
void
ObjFreeObj
(
struct
worker
*
,
struct
objcore
*
);
void
ObjSlim
(
struct
worker
*
,
struct
objcore
*
oc
);
void
ObjSlim
(
struct
worker
*
,
struct
objcore
*
);
struct
lru
*
ObjGetLRU
(
const
struct
objcore
*
);
int
ObjHasAttr
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
);
void
*
ObjGetAttr
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_attr
,
...
...
@@ -879,7 +880,7 @@ 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
);
int
ObjCheckFlag
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_flags
of
);
void
ObjSetFlag
(
struct
worker
*
,
struct
objcore
*
,
enum
obj_flags
of
,
int
val
);
/* cache_panic.c */
...
...
bin/varnishd/cache/cache_expire.c
View file @
f2882d3c
...
...
@@ -279,7 +279,6 @@ int
EXP_NukeOne
(
struct
worker
*
wrk
,
struct
lru
*
lru
)
{
struct
objcore
*
oc
,
*
oc2
;
struct
objhead
*
oh
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
lru
,
LRU_MAGIC
);
...
...
@@ -292,30 +291,12 @@ EXP_NukeOne(struct worker *wrk, struct lru *lru)
oc
,
oc
->
flags
,
oc
->
refcnt
);
AZ
(
oc
->
exp_flags
&
OC_EF_OFFLRU
);
AZ
(
oc
->
exp_flags
&
OC_EF_DYING
);
/*
* It wont release any space if we cannot release the last
* reference, besides, if somebody else has a reference,
* it's a bad idea to nuke this object anyway.
*/
if
(
oc
->
refcnt
>
1
)
continue
;
oh
=
oc
->
objhead
;
CHECK_OBJ_NOTNULL
(
oh
,
OBJHEAD_MAGIC
);
if
(
Lck_Trylock
(
&
oh
->
mtx
))
continue
;
if
(
oc
->
refcnt
==
1
)
{
oc
->
exp_flags
|=
OC_EF_DYING
|
OC_EF_OFFLRU
;
oc
->
refcnt
++
;
if
(
ObjKill
(
wrk
,
oc
))
{
VSC_C_main
->
n_lru_nuked
++
;
// XXX per lru ?
VTAILQ_REMOVE
(
&
lru
->
lru_head
,
oc
,
lru_list
);
}
else
{
oc
=
NULL
;
}
Lck_Unlock
(
&
oh
->
mtx
);
if
(
oc
!=
NULL
)
break
;
}
}
Lck_Unlock
(
&
lru
->
mtx
);
...
...
bin/varnishd/cache/cache_obj.c
View file @
f2882d3c
...
...
@@ -369,6 +369,35 @@ ObjTouch(struct worker *wrk, struct objcore *oc, double now)
om
->
objtouch
(
wrk
,
oc
,
now
);
}
/*====================================================================
* ObjKill()
*
* If objcore is idle, gain a ref and mark it dead.
*/
int
ObjKill
(
const
struct
worker
*
wrk
,
struct
objcore
*
oc
)
{
int
retval
=
0
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
CHECK_OBJ_NOTNULL
(
oc
->
objhead
,
OBJHEAD_MAGIC
);
AZ
(
oc
->
exp_flags
&
OC_EF_DYING
);
if
(
oc
->
refcnt
==
1
&&
!
Lck_Trylock
(
&
oc
->
objhead
->
mtx
))
{
if
(
oc
->
refcnt
==
1
)
{
oc
->
exp_flags
|=
OC_EF_DYING
;
oc
->
exp_flags
|=
OC_EF_OFFLRU
;
/* XXX */
oc
->
refcnt
++
;
retval
=
1
;
}
Lck_Unlock
(
&
oc
->
objhead
->
mtx
);
}
return
(
retval
);
}
/*====================================================================
* Utility functions which work on top of the previous ones
*/
...
...
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