[pypy-commit] pypy default: Prevent a race condition whereby thread B can still use an RFile
arigo
noreply at buildbot.pypy.org
Mon Feb 10 11:14:34 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r69116:0388bb74d17c
Date: 2014-02-10 11:13 +0100
http://bitbucket.org/pypy/pypy/changeset/0388bb74d17c/
Log: Prevent a race condition whereby thread B can still use an RFile
while thread A is blocked in the call to fclose() or pclose().
diff --git a/rpython/rlib/rfile.py b/rpython/rlib/rfile.py
--- a/rpython/rlib/rfile.py
+++ b/rpython/rlib/rfile.py
@@ -116,16 +116,16 @@
rffi.free_nonmovingbuffer(value, ll_value)
def close(self):
- if self.ll_file:
+ ll_f = self.ll_file
+ if ll_f:
# double close is allowed
- res = self._do_close()
self.ll_file = lltype.nullptr(FILE)
+ res = self._do_close(ll_f)
if res == -1:
errno = rposix.get_errno()
raise OSError(errno, os.strerror(errno))
- def _do_close(self):
- return c_close(self.ll_file)
+ _do_close = staticmethod(c_close) # overridden in RPopenFile
def read(self, size=-1):
# XXX CPython uses a more delicate logic here
@@ -258,6 +258,4 @@
class RPopenFile(RFile):
-
- def _do_close(self):
- return c_pclose(self.ll_file)
+ _do_close = staticmethod(c_pclose)
More information about the pypy-commit
mailing list