Tigthen assertions

Motivated by #40
parent 798fa608
......@@ -1131,8 +1131,12 @@ fellow_cache_lru_chgbatch_apply(struct fellow_lru_chgbatch *lcb)
//DBG("%u/%u", lcb->n, !VTAILQ_EMPTY(&lcb->add));
if (lcb->n_rem == 0 && VTAILQ_EMPTY(&lcb->add))
if (lcb->n_rem == 0 && (VTAILQ_EMPTY(&lcb->add) || lcb->n_add == 0)) {
AZ(lcb->n_rem);
AZ(lcb->n_add);
assert(VTAILQ_EMPTY(&lcb->add));
return;
}
fco = lcb->fco;
CHECK_OBJ_NOTNULL(fco, FELLOW_CACHE_OBJ_MAGIC);
......@@ -1142,15 +1146,22 @@ fellow_cache_lru_chgbatch_apply(struct fellow_lru_chgbatch *lcb)
n = lcb->n_rem;
while (n--) {
fcs = lcb->fcs[n];
CHECK_OBJ_NOTNULL(fcs, FELLOW_CACHE_SEG_MAGIC);
assert(fcs->fco == fco);
AZ(fcs->lcb_add);
AN(fcs->lcb_remove);
fcs->lcb_remove = 0;
}
n = 0;
VTAILQ_FOREACH(fcs, &lcb->add, lru_list) {
CHECK_OBJ_NOTNULL(fcs, FELLOW_CACHE_SEG_MAGIC);
assert(fcs->fco == fco);
AZ(fcs->lcb_remove);
AN(fcs->lcb_add);
fcs->lcb_add = 0;
n++;
}
assert(n == lcb->n_add);
AZ(pthread_mutex_lock(&lru->lru_mtx));
lru->n += lcb->n_add;
......@@ -1165,6 +1176,7 @@ fellow_cache_lru_chgbatch_apply(struct fellow_lru_chgbatch *lcb)
VTAILQ_CONCAT(&lru->lru_head, &lcb->add, lru_list);
AZ(pthread_mutex_unlock(&lru->lru_mtx));
lcb->n_add = 0;
assert(VTAILQ_EMPTY(&lcb->add));
AZ(lcb->n_rem);
}
......
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