[pypy-commit] pypy stm-gc: Can't call del_thread here. Multiple accesses to the dictionary
arigo
noreply at buildbot.pypy.org
Thu Feb 16 21:15:21 CET 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r52570:7333da24124f
Date: 2012-02-16 21:15 +0100
http://bitbucket.org/pypy/pypy/changeset/7333da24124f/
Log: Can't call del_thread here. Multiple accesses to the dictionary are
not protected by a lock. Instead, leave the stuff behind and clear
it from the main thread.
diff --git a/pypy/module/transaction/interp_transaction.py b/pypy/module/transaction/interp_transaction.py
--- a/pypy/module/transaction/interp_transaction.py
+++ b/pypy/module/transaction/interp_transaction.py
@@ -52,10 +52,6 @@
ec._transaction_pending = Fifo()
self.threadobjs[id] = ec
- def del_thread(self, id):
- # un-register a transaction thread
- del self.threadobjs[id]
-
# ---------- interface for ThreadLocals ----------
# This works really like a thread-local, which may have slightly
# strange consequences in multiple transactions, because you don't
@@ -79,6 +75,11 @@
def getallvalues(self):
return self.threadobjs
+ def clear_all_values_apart_from_main(self):
+ for id in self.threadobjs.keys():
+ if id != MAIN_THREAD_ID:
+ del self.threadobjs[id]
+
# ----------
def set_num_threads(self, num):
@@ -251,7 +252,6 @@
state.lock()
_add_list(my_transactions_pending)
#
- state.del_thread(rstm.thread_id())
rstm.descriptor_done()
if state.num_waiting_threads == 0: # only the last thread to leave
state.unlock_unfinished()
@@ -289,8 +289,8 @@
#
assert state.num_waiting_threads == 0
assert state.pending.is_empty()
- assert state.threadobjs.keys() == [MAIN_THREAD_ID]
assert not state.is_locked_no_tasks_pending()
+ state.clear_all_values_apart_from_main()
state.running = False
#
# now re-raise the exception that we got in a transaction
More information about the pypy-commit
mailing list