Commit dc39f2c2 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Try to make it more obvious what happens and answer a good question

with a resounding yes!
parent d20dc79b
...@@ -164,6 +164,13 @@ ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt, ...@@ -164,6 +164,13 @@ ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt,
return; return;
i = 0; i = 0;
VTAILQ_FOREACH_REVERSE_SAFE(bl, obans, banhead_s, l_list, bln) { VTAILQ_FOREACH_REVERSE_SAFE(bl, obans, banhead_s, l_list, bln) {
if (oc->ban != bt) {
/*
* HSH_Lookup() grabbed this oc, killed
* it or tested it to top. We're done.
*/
break;
}
if (bl->flags & BANS_FLAG_COMPLETED) { if (bl->flags & BANS_FLAG_COMPLETED) {
/* Ban was overtaken by new (dup) ban */ /* Ban was overtaken by new (dup) ban */
VTAILQ_REMOVE(obans, bl, l_list); VTAILQ_REMOVE(obans, bl, l_list);
...@@ -174,44 +181,27 @@ ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt, ...@@ -174,44 +181,27 @@ ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt,
i = ban_evaluate(wrk, bl->spec, oc, NULL, &tests); i = ban_evaluate(wrk, bl->spec, oc, NULL, &tests);
VSC_C_main->bans_lurker_tested++; VSC_C_main->bans_lurker_tested++;
VSC_C_main->bans_lurker_tests_tested += tests; VSC_C_main->bans_lurker_tests_tested += tests;
if (i) if (i) {
break; VSLb(vsl, SLT_ExpBan, "%u banned by lurker",
/* ObjGetXID(wrk, oc));
* XXX can we do this? can we safely assert that if HSH_Kill(oc);
* lookup has raced us it will have moved the oc VSC_C_main->bans_lurker_obj_killed++;
* above the olist?
*
if (oc->ban != bt)
break; break;
*/ }
} }
if (i) { if (i == 0 && oc->ban == bt) {
VSLb(vsl, SLT_ExpBan, "%u banned by lurker", Lck_Lock(&ban_mtx);
ObjGetXID(wrk, oc)); if (oc->ban == bt) {
bt->refcount--;
HSH_Kill(oc); VTAILQ_REMOVE(&bt->objcore, oc, ban_list);
VSC_C_main->bans_lurker_obj_killed++;
} else {
/*
* we race lookup-time ban checks - oc may have moved up
* the ban list already and we do not want to move it
* down again.
*/
while (oc->ban == bt) {
Lck_Lock(&ban_mtx);
if (oc->ban != bt) {
Lck_Unlock(&ban_mtx);
break;
}
oc->ban->refcount--;
VTAILQ_REMOVE(&oc->ban->objcore, oc, ban_list);
oc->ban = bd; oc->ban = bd;
bd->refcount++; bd->refcount++;
VTAILQ_INSERT_TAIL(&bd->objcore, oc, ban_list); VTAILQ_INSERT_TAIL(&bd->objcore, oc, ban_list);
Lck_Unlock(&ban_mtx); i = 1;
ObjSendEvent(wrk, oc, OEV_BANCHG);
break;
} }
Lck_Unlock(&ban_mtx);
if (i)
ObjSendEvent(wrk, oc, OEV_BANCHG);
} }
(void)HSH_DerefObjCore(wrk, &oc); (void)HSH_DerefObjCore(wrk, &oc);
} }
......
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