Revision: 2303
Author:
regra...@gmail.com
Date: Tue Jun 30 16:38:46 2015 UTC
Log: Fix problem where a certain order of triggered CT create and
frees could lead to a incorrect count of the triggered list items
https://code.google.com/p/portals4/source/detail?r=2303
Modified:
/trunk/src/ib/ptl_ct.c
=======================================
--- /trunk/src/ib/ptl_ct.c Thu Mar 12 15:55:21 2015 UTC
+++ /trunk/src/ib/ptl_ct.c Tue Jun 30 16:38:46 2015 UTC
@@ -73,6 +73,8 @@
ct_t *ct = arg;
ct->info.interrupt = 0;
+ ct->info.event.failure = 0;
+ ct->info.event.success = 0;
}
/**
@@ -201,7 +203,7 @@
/* remove ourselves from ni->ct_list */
PTL_FASTLOCK_LOCK(&ni->ct_list_lock);
list_del(&ct->list);
- if (atomic_read(&ct->list_size) > 0) {
+ while (atomic_read(&ct->list_size) > 1) {
atomic_dec(&ct->list_size);
}
PTL_FASTLOCK_UNLOCK(&ni->ct_list_lock);
@@ -210,9 +212,13 @@
ct->info.interrupt = 1;
ct_check(ct);
+ ct_cleanup(ct);
+ ptl_info("CT ref count before
free: %i\n",atomic_read(&ct->obj.obj_ref.ref_cnt));
ct_put(ct);
ct_put(ct);
+ ptl_info("CT freed\n");
+
/* give back the limit resource */
(void)__sync_sub_and_fetch(&ni->current.max_cts, 1);
@@ -658,9 +664,11 @@
(void)__sync_add_and_fetch(&ct->info.event.failure,
increment.failure);
+ ptl_info("CT inc, CT: %p new val: %i value inc'd by: %i
failures: %i\n",ct,ct->info.event.success,increment.success,ct->info.event.failure);
+
/* check to see if this triggers any further
* actions */
- if (atomic_read(&ct->list_size))
+ if (atomic_read(&ct->list_size) > 0)
ct_check(ct);
}
@@ -894,6 +902,7 @@
buf->type = BUF_TRIGGERED;
buf->op = TRIG_CT_SET;
buf->ct = ct;
+ //ct_set(ct, new_ct);
buf->ct_event = new_ct;
buf->threshold = threshold;
@@ -996,12 +1005,15 @@
if ((trig_ct->info.event.failure + trig_ct->info.event.success) >=
buf->threshold) {
PTL_FASTLOCK_UNLOCK(&trig_ct->lock);
-
+ ptl_info("triggered ct already met conditions\n");
do_trig_ct_op(buf);
} else {
+ ptl_info("ct value before inc for
triggered: %i\n",atomic_read(&trig_ct->list_size));
atomic_inc(&trig_ct->list_size);
+ ptl_info("triggered condition not met adding to list, list
lenght: %i\n",atomic_read(&trig_ct->list_size));
+
list_add(&buf->list, &trig_ct->trig_list);
/* We must check again to avoid a race with
make_ct_event/ct_inc_ct_set. */