[master] fd83702 Add a "posted" flag to keep track of oc's already mailed to exp
Poul-Henning Kamp
phk at FreeBSD.org
Wed Feb 3 23:45:28 CET 2016
commit fd83702a2d30003b8b0fd7b3c32640a8867403a0
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Feb 3 14:59:30 2016 +0000
Add a "posted" flag to keep track of oc's already mailed to exp
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 4a698ce..4d832a7 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -430,6 +430,7 @@ struct objcore {
#define OC_F_DYING (1<<7)
uint8_t exp_flags;
+#define OC_EF_POSTED (1<<1)
#define OC_EF_MOVE (1<<2)
#define OC_EF_INSERT (1<<3)
#define OC_EF_EXP (1<<4)
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index 89b8294..fd0b67a 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -143,11 +143,13 @@ exp_mail_it(struct objcore *oc, uint8_t cmds)
AN(isnan(oc->last_lru));
Lck_Lock(&exphdl->mtx);
- oc->exp_flags |= cmds;
- if (oc->flags & OC_F_DYING)
- VSTAILQ_INSERT_HEAD(&exphdl->inbox, oc, exp_list);
- else
- VSTAILQ_INSERT_TAIL(&exphdl->inbox, oc, exp_list);
+ if (!(oc->exp_flags & OC_EF_POSTED)) {
+ if (oc->flags & OC_F_DYING)
+ VSTAILQ_INSERT_HEAD(&exphdl->inbox, oc, exp_list);
+ else
+ VSTAILQ_INSERT_TAIL(&exphdl->inbox, oc, exp_list);
+ }
+ oc->exp_flags |= cmds | OC_EF_POSTED;
VSC_C_main->exp_mailed++;
AZ(pthread_cond_signal(&exphdl->condvar));
Lck_Unlock(&exphdl->mtx);
@@ -355,9 +357,8 @@ EXP_Deregister_Callback(uintptr_t *handle)
*/
static void
-exp_inbox(struct exp_priv *ep, struct objcore *oc, double now)
+exp_inbox(struct exp_priv *ep, struct objcore *oc, double now, unsigned flags)
{
- unsigned flags;
struct lru *lru;
CHECK_OBJ_NOTNULL(ep, EXP_PRIV_MAGIC);
@@ -369,12 +370,6 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, double now)
lru = ObjGetLRU(oc);
CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
- /* Evacuate our action-flags, and put it back on the LRU list */
- Lck_Lock(&ep->mtx);
- flags = oc->exp_flags;
- oc->exp_flags &= ~(OC_EF_INSERT | OC_EF_MOVE);
- Lck_Unlock(&ep->mtx);
-
Lck_Lock(&lru->mtx);
AN(isnan(oc->last_lru));
oc->last_lru = now;
@@ -512,6 +507,7 @@ exp_thread(struct worker *wrk, void *priv)
struct objcore *oc;
double t = 0, tnext = 0;
struct exp_priv *ep;
+ unsigned flags = 0;
CAST_OBJ_NOTNULL(ep, priv, EXP_PRIV_MAGIC);
ep->wrk = wrk;
@@ -526,6 +522,9 @@ exp_thread(struct worker *wrk, void *priv)
VSTAILQ_REMOVE(&ep->inbox, oc, objcore, exp_list);
VSC_C_main->exp_received++;
tnext = 0;
+ flags = oc->exp_flags;
+ oc->exp_flags &=
+ ~(OC_EF_INSERT | OC_EF_MOVE | OC_EF_POSTED);
} else if (tnext > t) {
VSL_Flush(&ep->vsl, 0);
Pool_Sumstat(wrk);
@@ -536,7 +535,7 @@ exp_thread(struct worker *wrk, void *priv)
t = VTIM_real();
if (oc != NULL)
- exp_inbox(ep, oc, t);
+ exp_inbox(ep, oc, t, flags);
else
tnext = exp_expire(ep, t);
}
More information about the varnish-commit
mailing list