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
8697257d
Commit
8697257d
authored
Feb 03, 2016
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send EXP_NukeOne() over to storage_simple where it belongs (more)
parent
fd83702a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
47 deletions
+61
-47
cache.h
bin/varnishd/cache/cache.h
+1
-0
cache_expire.c
bin/varnishd/cache/cache_expire.c
+12
-47
storage_simple.c
bin/varnishd/storage/storage_simple.c
+48
-0
No files found.
bin/varnishd/cache/cache.h
View file @
8697257d
...
...
@@ -695,6 +695,7 @@ void EXP_Insert(struct worker *wrk, struct objcore *oc);
void
EXP_Inject
(
struct
worker
*
wrk
,
struct
objcore
*
oc
,
struct
lru
*
lru
);
void
EXP_Rearm
(
struct
objcore
*
,
double
now
,
double
ttl
,
double
grace
,
double
keep
);
void
EXP_Poke
(
struct
objcore
*
);
int
EXP_NukeOne
(
struct
worker
*
wrk
,
struct
lru
*
lru
);
enum
exp_event_e
{
...
...
bin/varnishd/cache/cache_expire.c
View file @
8697257d
...
...
@@ -155,6 +155,18 @@ exp_mail_it(struct objcore *oc, uint8_t cmds)
Lck_Unlock
(
&
exphdl
->
mtx
);
}
/*--------------------------------------------------------------------
* Call EXP's attention to a an oc
*/
void
EXP_Poke
(
struct
objcore
*
oc
)
{
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
exp_mail_it
(
oc
,
0
);
}
/*--------------------------------------------------------------------
* Inject an object with a reference into the lru/binheap.
*
...
...
@@ -266,53 +278,6 @@ EXP_Rearm(struct objcore *oc, double now, double ttl, double grace, double keep)
exp_mail_it
(
oc
,
OC_EF_MOVE
);
}
/*--------------------------------------------------------------------
* Attempt to make space by nuking the oldest object on the LRU list
* which isn't in use.
* Returns: 1: did, 0: didn't, -1: can't
*/
int
EXP_NukeOne
(
struct
worker
*
wrk
,
struct
lru
*
lru
)
{
struct
objcore
*
oc
,
*
oc2
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
lru
,
LRU_MAGIC
);
/* Find the first currently unused object on the LRU. */
Lck_Lock
(
&
lru
->
mtx
);
VTAILQ_FOREACH_SAFE
(
oc
,
&
lru
->
lru_head
,
lru_list
,
oc2
)
{
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
VSLb
(
wrk
->
vsl
,
SLT_ExpKill
,
"LRU_Cand p=%p f=0x%x r=%d"
,
oc
,
oc
->
flags
,
oc
->
refcnt
);
AZ
(
isnan
(
oc
->
last_lru
));
if
(
ObjSnipe
(
wrk
,
oc
))
{
VSC_C_main
->
n_lru_nuked
++
;
// XXX per lru ?
VTAILQ_REMOVE
(
&
lru
->
lru_head
,
oc
,
lru_list
);
oc
->
last_lru
=
NAN
;
break
;
}
}
Lck_Unlock
(
&
lru
->
mtx
);
if
(
oc
==
NULL
)
{
VSLb
(
wrk
->
vsl
,
SLT_ExpKill
,
"LRU_Fail"
);
return
(
-
1
);
}
/* XXX: We could grab and return one storage segment to our caller */
ObjSlim
(
wrk
,
oc
);
exp_mail_it
(
oc
,
0
);
VSLb
(
wrk
->
vsl
,
SLT_ExpKill
,
"LRU x=%u"
,
ObjGetXID
(
wrk
,
oc
));
(
void
)
HSH_DerefObjCore
(
wrk
,
&
oc
);
return
(
1
);
}
/*--------------------------------------------------------------------*/
uintptr_t
...
...
bin/varnishd/storage/storage_simple.c
View file @
8697257d
...
...
@@ -39,6 +39,54 @@
#include "storage/storage.h"
#include "storage/storage_simple.h"
/*--------------------------------------------------------------------
* Attempt to make space by nuking the oldest object on the LRU list
* which isn't in use.
* Returns: 1: did, 0: didn't, -1: can't
*/
int
EXP_NukeOne
(
struct
worker
*
wrk
,
struct
lru
*
lru
)
{
struct
objcore
*
oc
,
*
oc2
;
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
lru
,
LRU_MAGIC
);
/* Find the first currently unused object on the LRU. */
Lck_Lock
(
&
lru
->
mtx
);
VTAILQ_FOREACH_SAFE
(
oc
,
&
lru
->
lru_head
,
lru_list
,
oc2
)
{
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
VSLb
(
wrk
->
vsl
,
SLT_ExpKill
,
"LRU_Cand p=%p f=0x%x r=%d"
,
oc
,
oc
->
flags
,
oc
->
refcnt
);
AZ
(
isnan
(
oc
->
last_lru
));
if
(
ObjSnipe
(
wrk
,
oc
))
{
VSC_C_main
->
n_lru_nuked
++
;
// XXX per lru ?
VTAILQ_REMOVE
(
&
lru
->
lru_head
,
oc
,
lru_list
);
oc
->
last_lru
=
NAN
;
break
;
}
}
Lck_Unlock
(
&
lru
->
mtx
);
if
(
oc
==
NULL
)
{
VSLb
(
wrk
->
vsl
,
SLT_ExpKill
,
"LRU_Fail"
);
return
(
-
1
);
}
/* XXX: We could grab and return one storage segment to our caller */
ObjSlim
(
wrk
,
oc
);
EXP_Poke
(
oc
);
VSLb
(
wrk
->
vsl
,
SLT_ExpKill
,
"LRU x=%u"
,
ObjGetXID
(
wrk
,
oc
));
(
void
)
HSH_DerefObjCore
(
wrk
,
&
oc
);
return
(
1
);
}
/*-------------------------------------------------------------------*/
static
struct
storage
*
...
...
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