[master] 9dea74f Prepare hsh_rush1 for rush limit
Nils Goroll
nils.goroll at uplex.de
Thu Jun 16 12:14:07 CEST 2016
commit 9dea74f7a3589fe6e3d40ca9f86f43ac3c95d457
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Wed May 11 12:20:11 2016 +0200
Prepare hsh_rush1 for rush limit
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index c552416..ddb23fa 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -302,7 +302,7 @@ HSH_Insert(struct worker *wrk, const void *digest, struct objcore *oc,
VTAILQ_INSERT_HEAD(&oh->objcs, oc, hsh_list);
oc->flags &= ~OC_F_BUSY;
if (!VTAILQ_EMPTY(&oh->waitinglist))
- hsh_rush1(wrk, oh, &rush, 0);
+ hsh_rush1(wrk, oh, &rush, HSH_RUSH_POLICY);
Lck_Unlock(&oh->mtx);
hsh_rush2(wrk, &rush);
}
@@ -519,17 +519,23 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
*/
static void
-hsh_rush1(struct worker *wrk, struct objhead *oh, struct rush *r, int all)
+hsh_rush1(struct worker *wrk, struct objhead *oh, struct rush *r, int max)
{
unsigned u;
struct req *req;
+ if (max == 0)
+ return;
+ if (max == HSH_RUSH_POLICY)
+ max = cache_param->rush_exponent;
+ assert(max > 0);
+
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
CHECK_OBJ_NOTNULL(r, RUSH_MAGIC);
VTAILQ_INIT(&r->reqs);
Lck_AssertHeld(&oh->mtx);
- for (u = 0; u < cache_param->rush_exponent || all; u++) {
+ for (u = 0; u < max; u++) {
req = VTAILQ_FIRST(&oh->waitinglist);
if (req == NULL)
break;
@@ -706,7 +712,7 @@ HSH_Unbusy(struct worker *wrk, struct objcore *oc)
VTAILQ_INSERT_HEAD(&oh->objcs, oc, hsh_list);
oc->flags &= ~OC_F_BUSY;
if (!VTAILQ_EMPTY(&oh->waitinglist))
- hsh_rush1(wrk, oh, &rush, 0);
+ hsh_rush1(wrk, oh, &rush, HSH_RUSH_POLICY);
Lck_Unlock(&oh->mtx);
if (!(oc->flags & OC_F_PRIVATE))
EXP_Insert(wrk, oc);
@@ -862,7 +868,7 @@ HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp)
if (!r)
VTAILQ_REMOVE(&oh->objcs, oc, hsh_list);
if (!VTAILQ_EMPTY(&oh->waitinglist))
- hsh_rush1(wrk, oh, &rush, 0);
+ hsh_rush1(wrk, oh, &rush, HSH_RUSH_POLICY);
Lck_Unlock(&oh->mtx);
hsh_rush2(wrk, &rush);
if (r != 0)
@@ -913,7 +919,7 @@ HSH_DerefObjHead(struct worker *wrk, struct objhead **poh)
*/
Lck_Lock(&oh->mtx);
while (oh->refcnt == 1 && !VTAILQ_EMPTY(&oh->waitinglist)) {
- hsh_rush1(wrk, oh, &rush, 1);
+ hsh_rush1(wrk, oh, &rush, HSH_RUSH_ALL);
Lck_Unlock(&oh->mtx);
hsh_rush2(wrk, &rush);
Lck_Lock(&oh->mtx);
diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h
index 7743dec..d9e169a 100644
--- a/bin/varnishd/hash/hash_slinger.h
+++ b/bin/varnishd/hash/hash_slinger.h
@@ -110,6 +110,8 @@ void HSH_Unbusy(struct worker *, struct objcore *);
void HSH_DeleteObjHead(struct worker *, struct objhead *oh);
int HSH_DerefObjHead(struct worker *, struct objhead **poh);
int HSH_DerefObjCore(struct worker *, struct objcore **ocp);
+#define HSH_RUSH_POLICY -1
+#define HSH_RUSH_ALL INT_MAX
#endif /* VARNISH_CACHE_CHILD */
extern const struct hash_slinger hsl_slinger;
More information about the varnish-commit
mailing list