Author: Armin Rigo <[email protected]>
Branch: stm-gc
Changeset: r54589:c255347d4061
Date: 2012-04-20 19:00 +0200
http://bitbucket.org/pypy/pypy/changeset/c255347d4061/

Log:    Fix epoll too.

diff --git a/pypy/module/transaction/interp_epoll.py 
b/pypy/module/transaction/interp_epoll.py
--- a/pypy/module/transaction/interp_epoll.py
+++ b/pypy/module/transaction/interp_epoll.py
@@ -45,8 +45,8 @@
 
     def run(self):
         # This code is run non-transactionally.  Careful, no GC available.
-        state = interp_transaction.state
-        if state.has_exception() or self.force_quit:
+        ts = interp_transaction.state.transactionalstate
+        if ts.has_exception() or self.force_quit:
             return
         fd = rffi.cast(rffi.INT, self.epoller.epfd)
         maxevents = rffi.cast(rffi.INT, self.maxevents)
@@ -60,9 +60,9 @@
                 nfds = 0    # ignore, just wait for more later
             else:
                 # unsure how to trigger this case
-                state = interp_transaction.state
-                state.got_exception_errno = errno
-                state.must_reraise_exception(_reraise_from_errno)
+                ts = interp_transaction.state.transactionalstate
+                ts.got_exception_errno = errno
+                ts.must_reraise_exception(_reraise_from_errno)
                 return
         # We have to allocate new PendingCallback objects, but we can't
         # allocate anything here because we are not running transactionally.
@@ -96,10 +96,9 @@
                                              space.wrap(self.events))
 
 
-def _reraise_from_errno():
-    state = interp_transaction.state
-    space = state.space
-    errno = state.got_exception_errno
+def _reraise_from_errno(transactionalstate):
+    space = interp_transaction.state.space
+    errno = transactionalstate.got_exception_errno
     msg = os.strerror(errno)
     w_type = space.w_IOError
     w_error = space.call_function(w_type, space.wrap(errno), space.wrap(msg))
@@ -109,9 +108,7 @@
 @unwrap_spec(epoller=W_Epoll)
 def add_epoll(space, epoller, w_callback):
     state = interp_transaction.state
-    if state.epolls is None:
-        state.epolls = {}
-    elif epoller in state.epolls:
+    if epoller in state.epolls:
         raise OperationError(state.w_error,
             space.wrap("add_epoll(ep): ep is already registered"))
     pending = EPollPending(space, epoller, w_callback)
@@ -121,10 +118,7 @@
 @unwrap_spec(epoller=W_Epoll)
 def remove_epoll(space, epoller):
     state = interp_transaction.state
-    if state.epolls is None:
-        pending = None
-    else:
-        pending = state.epolls.get(epoller, None)
+    pending = state.epolls.get(epoller, None)
     if pending is None:
         raise OperationError(state.w_error,
             space.wrap("remove_epoll(ep): ep is not registered"))
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
@@ -34,6 +34,7 @@
         self.ll_not_ready_to_start_lock = threadintf.null_ll_lock
         self.threadobjs = {}      # empty during translation
         self.threadnums = {}      # empty during translation
+        self.epolls = {}
         self.pending = Fifo()
 
     def _freeze_(self):
@@ -95,6 +96,7 @@
             if id != MAIN_THREAD_ID:
                 del self.threadobjs[id]
         self.threadnums = {MAIN_THREAD_ID: 0}
+        self.epolls.clear()
 
     def get_thread_number(self):
         id = rstm.thread_id()
@@ -163,7 +165,6 @@
 
     def __init__(self):
         self._reraise_exception = None
-        self.epolls = None
 
     def has_exception(self):
         return self._reraise_exception is not None
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to