Commit 4ded44b6 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make DYING a main Obj flag, add a function to set it (ObjKill)

and end random code mucking about with it.
parent d2257489
......@@ -427,12 +427,12 @@ struct objcore {
#define OC_F_ABANDON (1<<4)
#define OC_F_PRIVATE (1<<5)
#define OC_F_FAILED (1<<6)
#define OC_F_DYING (1<<7)
uint8_t exp_flags;
#define OC_EF_MOVE (1<<2)
#define OC_EF_INSERT (1<<3)
#define OC_EF_EXP (1<<4)
#define OC_EF_DYING (1<<5)
uint16_t oa_present;
......@@ -858,6 +858,7 @@ void ObjWaitState(const struct objcore *, enum boc_state_e want);
void ObjTrimStore(struct worker *, struct objcore *);
void ObjTouch(struct worker *, struct objcore *, double now);
int ObjSnipe(const struct worker *, struct objcore *);
void ObjKill(struct objcore *);
unsigned ObjGetXID(struct worker *, struct objcore *);
uint64_t ObjGetLen(struct worker *, struct objcore *);
void ObjUpdateMeta(struct worker *, struct objcore *);
......
......@@ -143,7 +143,7 @@ exp_mail_it(struct objcore *oc)
AN(oc->lru_flags & OC_LRU_OFFLRU);
Lck_Lock(&exphdl->mtx);
if (oc->exp_flags & OC_EF_DYING)
if (oc->flags & OC_F_DYING)
VTAILQ_INSERT_HEAD(&exphdl->inbox, oc, lru_list);
else
VTAILQ_INSERT_TAIL(&exphdl->inbox, oc, lru_list);
......@@ -168,7 +168,7 @@ EXP_Inject(struct worker *wrk, struct objcore *oc, struct lru *lru)
AZ(oc->lru_flags & OC_LRU_OFFLRU);
AZ(oc->exp_flags & (OC_EF_INSERT | OC_EF_MOVE));
AZ(oc->exp_flags & OC_EF_DYING);
AZ(oc->flags & OC_F_DYING);
AZ(oc->flags & OC_F_BUSY);
CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
......@@ -202,7 +202,7 @@ EXP_Insert(struct worker *wrk, struct objcore *oc)
AZ(oc->lru_flags & OC_LRU_OFFLRU);
AZ(oc->exp_flags & (OC_EF_INSERT | OC_EF_MOVE));
AZ(oc->exp_flags & OC_EF_DYING);
AZ(oc->flags & OC_F_DYING);
AN(oc->flags & OC_F_BUSY);
lru = ObjGetLRU(oc);
......@@ -256,15 +256,11 @@ EXP_Rearm(struct objcore *oc, double now, double ttl, double grace, double keep)
Lck_Lock(&lru->mtx);
if (!isnan(now) && when <= now)
oc->exp_flags |= OC_EF_DYING;
else
oc->exp_flags |= OC_EF_MOVE;
if (oc->lru_flags & OC_LRU_OFFLRU) {
oc = NULL;
} else {
oc->lru_flags |= OC_LRU_OFFLRU;
oc->exp_flags |= OC_EF_MOVE;
VTAILQ_REMOVE(&lru->lru_head, oc, lru_list);
}
Lck_Unlock(&lru->mtx);
......@@ -384,13 +380,13 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, double now)
AN(oc->lru_flags & OC_LRU_OFFLRU);
oc->exp_flags &= ~(OC_EF_INSERT | OC_EF_MOVE);
oc->last_lru = now;
if (!(flags & OC_EF_DYING)) {
if (!(oc->flags & OC_F_DYING)) {
VTAILQ_INSERT_TAIL(&lru->lru_head, oc, lru_list);
oc->lru_flags &= ~OC_LRU_OFFLRU;
}
Lck_Unlock(&lru->mtx);
if (flags & OC_EF_DYING) {
if (oc->flags & OC_F_DYING) {
VSLb(&ep->vsl, SLT_ExpKill, "EXP_Kill p=%p e=%.9f f=0x%x", oc,
oc->timer_when, oc->flags);
if (!(flags & OC_EF_INSERT)) {
......@@ -458,7 +454,8 @@ exp_expire(struct exp_priv *ep, double now)
CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
Lck_Lock(&lru->mtx);
oc->exp_flags |= OC_EF_DYING;
if (!(oc->flags & OC_F_DYING))
ObjKill(oc);
if (oc->lru_flags & OC_LRU_OFFLRU)
oc = NULL;
else {
......
......@@ -393,7 +393,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
assert(oc->objhead == oh);
if (oc->exp_flags & OC_EF_DYING)
if (oc->flags & OC_F_DYING)
continue;
if (oc->flags & OC_F_FAILED)
continue;
......@@ -415,8 +415,10 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
if (oc->exp.ttl <= 0.)
continue;
if (BAN_CheckObject(wrk, oc, req))
if (BAN_CheckObject(wrk, oc, req)) {
oc->flags |= OC_F_DYING;
continue;
}
if (ObjHasAttr(wrk, oc, OA_VARY)) {
vary = ObjGetAttr(wrk, oc, OA_VARY, NULL);
......@@ -585,7 +587,7 @@ double keep)
*/
continue;
}
if (oc->exp_flags & OC_EF_DYING)
if (oc->flags & OC_F_DYING)
continue;
if (spc < sizeof *ocp) {
/* Iterate if aws is not big enough */
......
......@@ -369,6 +369,26 @@ ObjTouch(struct worker *wrk, struct objcore *oc, double now)
om->objtouch(wrk, oc, now);
}
/*====================================================================
* ObjKill()
*
* It's dead Jim, kick it...
*/
void
ObjKill(struct objcore *oc)
{
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
AZ(oc->flags & OC_F_DYING); // XXX ?
Lck_Lock(&oc->objhead->mtx);
oc->flags |= OC_F_DYING;
Lck_Unlock(&oc->objhead->mtx);
}
/*====================================================================
* ObjSnipe()
*
......@@ -384,11 +404,11 @@ ObjSnipe(const struct worker *wrk, struct objcore *oc)
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
AZ(oc->exp_flags & OC_EF_DYING);
AZ(oc->flags & OC_F_DYING);
if (oc->refcnt == 1 && !Lck_Trylock(&oc->objhead->mtx)) {
if (oc->refcnt == 1) {
oc->exp_flags |= OC_EF_DYING;
oc->flags |= OC_F_DYING;
oc->refcnt++;
retval = 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment