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
61b722b6
Commit
61b722b6
authored
Apr 09, 2013
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move always_miss check up front to get it over with.
parent
e6f12e90
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
12 deletions
+60
-12
cache_hash.c
bin/varnishd/cache/cache_hash.c
+55
-10
cache_req_fsm.c
bin/varnishd/cache/cache_req_fsm.c
+4
-1
hash_slinger.h
bin/varnishd/hash/hash_slinger.h
+1
-1
No files found.
bin/varnishd/cache/cache_hash.c
View file @
61b722b6
...
...
@@ -285,8 +285,50 @@ HSH_Insert(struct worker *wrk, const void *digest, struct objcore *oc)
/*---------------------------------------------------------------------
*/
static
struct
objcore
*
hsh_insert_busyobj
(
struct
worker
*
wrk
,
struct
objhead
*
oh
)
{
struct
objcore
*
oc
;
CHECK_OBJ_NOTNULL
(
oh
,
OBJHEAD_MAGIC
);
oc
=
wrk
->
nobjcore
;
wrk
->
nobjcore
=
NULL
;
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
AN
(
oc
->
flags
&
OC_F_BUSY
);
oc
->
refcnt
=
1
;
/* Owned by busyobj */
oc
->
objhead
=
oh
;
VTAILQ_INSERT_TAIL
(
&
oh
->
objcs
,
oc
,
list
);
return
(
oc
);
}
/*---------------------------------------------------------------------
* XXX: future action:
*
* if (always_miss)
* return (insert_busy_obj())
* switch (Lookup()) {
* case HIT:
* return (object);
* case BUSY_ONLY:
* if (!ignore_body)
* return (WAIT)
* // fallthrough
* case MISS:
* return (insert_busy_obj())
* case EXPIRED_AND_BUSY:
* if (!ignore_body)
* return (expired_object)
* // fallthrough
* case EXPIRED:
* return (expired_object + insert_busy_obj())
* }
*
*/
struct
objcore
*
HSH_Lookup
(
struct
req
*
req
,
int
wait_for_busy
)
HSH_Lookup
(
struct
req
*
req
,
int
wait_for_busy
,
int
always_insert
)
{
struct
worker
*
wrk
;
struct
objhead
*
oh
;
...
...
@@ -324,6 +366,14 @@ HSH_Lookup(struct req *req, int wait_for_busy)
CHECK_OBJ_NOTNULL
(
oh
,
OBJHEAD_MAGIC
);
Lck_AssertHeld
(
&
oh
->
mtx
);
if
(
always_insert
)
{
/* Insert new objcore in objecthead and release mutex */
oc
=
hsh_insert_busyobj
(
wrk
,
oh
);
/* NB: no deref of objhead, new object inherits reference */
Lck_Unlock
(
&
oh
->
mtx
);
return
(
oc
);
}
assert
(
oh
->
refcnt
>
0
);
busy_found
=
0
;
grace_oc
=
NULL
;
...
...
@@ -336,7 +386,7 @@ HSH_Lookup(struct req *req, int wait_for_busy)
if
(
oc
->
flags
&
OC_F_BUSY
||
oc
->
busyobj
!=
NULL
)
{
CHECK_OBJ_ORNULL
(
oc
->
busyobj
,
BUSYOBJ_MAGIC
);
if
(
req
->
hash_ignore_busy
||
req
->
hash_always_miss
)
if
(
req
->
hash_ignore_busy
)
continue
;
if
(
oc
->
busyobj
!=
NULL
&&
...
...
@@ -393,7 +443,7 @@ HSH_Lookup(struct req *req, int wait_for_busy)
oc
=
grace_oc
;
}
if
(
oc
!=
NULL
&&
!
req
->
hash_always_miss
)
{
if
(
oc
!=
NULL
)
{
/* We found an object we like */
assert
(
oh
->
refcnt
>
1
);
assert
(
oc
->
objhead
==
oh
);
...
...
@@ -440,13 +490,8 @@ HSH_Lookup(struct req *req, int wait_for_busy)
}
/* Insert (precreated) objcore in objecthead and release mutex */
oc
=
wrk
->
nobjcore
;
wrk
->
nobjcore
=
NULL
;
AN
(
oc
->
flags
&
OC_F_BUSY
);
oc
->
refcnt
=
1
;
/* Owned by busyobj */
oc
->
objhead
=
oh
;
VTAILQ_INSERT_TAIL
(
&
oh
->
objcs
,
oc
,
list
);
/* NB: do not deref objhead the new object inherits our reference */
oc
=
hsh_insert_busyobj
(
wrk
,
oh
);
/* NB: no deref of objhead, new object inherits reference */
Lck_Unlock
(
&
oh
->
mtx
);
return
(
oc
);
}
...
...
bin/varnishd/cache/cache_req_fsm.c
View file @
61b722b6
...
...
@@ -751,7 +751,10 @@ cnt_lookup(struct worker *wrk, struct req *req)
VRY_Prep
(
req
);
AZ
(
req
->
objcore
);
oc
=
HSH_Lookup
(
req
,
req
->
esi_level
==
0
?
1
:
0
);
oc
=
HSH_Lookup
(
req
,
req
->
esi_level
==
0
?
1
:
0
,
req
->
hash_always_miss
?
1
:
0
);
if
(
oc
==
NULL
)
{
/*
* We lost the session to a busy object, disembark the
...
...
bin/varnishd/hash/hash_slinger.h
View file @
61b722b6
...
...
@@ -53,7 +53,7 @@ struct hash_slinger {
/* cache_hash.c */
void
HSH_Cleanup
(
struct
worker
*
w
);
struct
objcore
*
HSH_Lookup
(
struct
req
*
,
int
wait_for_busy
);
struct
objcore
*
HSH_Lookup
(
struct
req
*
,
int
wait_for_busy
,
int
always_insert
);
void
HSH_Ref
(
struct
objcore
*
o
);
void
HSH_Drop
(
struct
worker
*
,
struct
object
**
);
void
HSH_Init
(
const
struct
hash_slinger
*
slinger
);
...
...
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