Author: Armin Rigo <[email protected]>
Branch: stm-thread
Changeset: r54934:26ab48d36ec4
Date: 2012-05-07 13:30 +0200
http://bitbucket.org/pypy/pypy/changeset/26ab48d36ec4/

Log:    Save and restore the errno, like module/thread/gil.py does.

diff --git a/pypy/rlib/rstm.py b/pypy/rlib/rstm.py
--- a/pypy/rlib/rstm.py
+++ b/pypy/rlib/rstm.py
@@ -3,6 +3,7 @@
 from pypy.rlib.debug import ll_assert, fatalerror
 from pypy.rlib.objectmodel import keepalive_until_here, specialize
 from pypy.rlib.objectmodel import we_are_translated
+from pypy.rlib.rposix import get_errno, set_errno
 from pypy.rpython.lltypesystem import lltype, llmemory, rffi, rclass
 from pypy.rpython.lltypesystem.lloperation import llop
 from pypy.rpython.annlowlevel import (cast_base_ptr_to_instance,
@@ -13,34 +14,42 @@
     return we_are_translated() and stmgcintf.StmOperations.is_inevitable()
 
 def before_external_call():
+    e = get_errno()
     llop.stm_stop_transaction(lltype.Void)
     stmgcintf.StmOperations.commit_transaction()
+    set_errno(e)
 before_external_call._dont_reach_me_in_del_ = True
 before_external_call._transaction_break_ = True
 
 def after_external_call():
+    e = get_errno()
     stmgcintf.StmOperations.begin_inevitable_transaction()
     llop.stm_start_transaction(lltype.Void)
+    set_errno(e)
 after_external_call._dont_reach_me_in_del_ = True
 after_external_call._transaction_break_ = True
 
 def enter_callback_call():
+    e = get_errno()
     token = stmgcintf.StmOperations.descriptor_init()
     stmgcintf.StmOperations.begin_inevitable_transaction()
     if token != 1:
         llop.stm_start_transaction(lltype.Void)
     #else: the StmGCTLS is not built yet.  leave it to gc_thread_start()
+    set_errno(e)
     return token
 enter_callback_call._dont_reach_me_in_del_ = True
 enter_callback_call._transaction_break_ = True
 
 def leave_callback_call(token):
+    e = get_errno()
     if token != 1:
         llop.stm_stop_transaction(lltype.Void)
     #else: the StmGCTLS is already destroyed, done by gc_thread_die()
     stmgcintf.StmOperations.commit_transaction()
     if token == 1:
         stmgcintf.StmOperations.descriptor_done()
+    set_errno(e)
 leave_callback_call._dont_reach_me_in_del_ = True
 leave_callback_call._transaction_break_ = True
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to