Rev 4716: (andrew) Check for SIGINT after EINTR in _readdir_pyx extension. in file:///home/pqm/archives/thelove/bzr/2.0/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Jan 4 01:15:22 GMT 2010
At file:///home/pqm/archives/thelove/bzr/2.0/
------------------------------------------------------------
revno: 4716 [merge]
revision-id: pqm at pqm.ubuntu.com-20100104011521-lkufz3tammak5mxx
parent: pqm at pqm.ubuntu.com-20091222061855-scbiyuohoxoltr1y
parent: andrew.bennetts at canonical.com-20091223021904-6pu6q0mrbrejcixs
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.0
timestamp: Mon 2010-01-04 01:15:21 +0000
message:
(andrew) Check for SIGINT after EINTR in _readdir_pyx extension.
(#495023)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/_readdir_pyx.pyx readdir.pyx-20060609152855-rm6v321vuaqyh9tu-1
=== modified file 'NEWS'
--- a/NEWS 2009-12-22 04:10:41 +0000
+++ b/NEWS 2009-12-23 02:19:04 +0000
@@ -31,6 +31,10 @@
This will likely have an impact on any other process that is serving for
an extended period of time. (John Arbash Meinel, #494406)
+* Check for SIGINT (Ctrl-C) and other signals immediately if ``readdir``
+ returns ``EINTR`` by calling ``PyErr_CheckSignals``. This affected the
+ optional ``_readdir_pyx`` extension. (Andrew Bennetts, #495023)
+
* Give a clearer message if the lockdir disappears after being apparently
successfully taken. (Martin Pool, #498378)
=== modified file 'bzrlib/_readdir_pyx.pyx'
--- a/bzrlib/_readdir_pyx.pyx 2009-10-08 07:03:05 +0000
+++ b/bzrlib/_readdir_pyx.pyx 2009-12-23 02:19:04 +0000
@@ -78,6 +78,7 @@
cdef extern from 'Python.h':
+ int PyErr_CheckSignals() except -1
char * PyString_AS_STRING(object)
ctypedef int Py_ssize_t # Required for older pyrex versions
ctypedef struct PyObject:
@@ -271,6 +272,12 @@
return result
+cdef raise_os_error(int errnum, char *msg_prefix, path):
+ if errnum == EINTR:
+ PyErr_CheckSignals()
+ raise OSError(errnum, msg_prefix + strerror(errnum), path)
+
+
cdef _read_dir(path):
"""Like os.listdir, this reads the contents of a directory.
@@ -298,16 +305,16 @@
# passing full paths every time.
orig_dir_fd = open(".", O_RDONLY, 0)
if orig_dir_fd == -1:
- raise OSError(errno, "open: " + strerror(errno), ".")
+ raise_os_error(errno, "open: ", ".")
if -1 == chdir(path):
- raise OSError(errno, "chdir: " + strerror(errno), path)
+ raise_os_error(errno, "chdir: ", path)
else:
orig_dir_fd = -1
try:
the_dir = opendir(".")
if NULL == the_dir:
- raise OSError(errno, "opendir: " + strerror(errno), path)
+ raise_os_error(errno, "opendir: ", path)
try:
result = []
entry = &sentinel
@@ -319,6 +326,8 @@
errno = 0
entry = readdir(the_dir)
if entry == NULL and (errno == EAGAIN or errno == EINTR):
+ if errno == EINTR:
+ PyErr_CheckSignals()
# try again
continue
else:
@@ -330,7 +339,7 @@
# we consider ENOTDIR to be 'no error'.
continue
else:
- raise OSError(errno, "readdir: " + strerror(errno), path)
+ raise_os_error(errno, "readdir: ", path)
name = entry.d_name
if not (name[0] == c"." and (
(name[1] == 0) or
@@ -340,7 +349,7 @@
stat_result = lstat(entry.d_name, &statvalue._st)
if stat_result != 0:
if errno != ENOENT:
- raise OSError(errno, "lstat: " + strerror(errno),
+ raise_os_error(errno, "lstat: ",
path + "/" + entry.d_name)
else:
# the file seems to have disappeared after being
@@ -358,7 +367,7 @@
statvalue, None))
finally:
if -1 == closedir(the_dir):
- raise OSError(errno, "closedir: " + strerror(errno), path)
+ raise_os_error(errno, "closedir: ", path)
finally:
if -1 != orig_dir_fd:
failed = False
@@ -366,7 +375,7 @@
# try to close the original directory anyhow
failed = True
if -1 == close(orig_dir_fd) or failed:
- raise OSError(errno, "return to orig_dir: " + strerror(errno))
+ raise_os_error(errno, "return to orig_dir: ", "")
return result
More information about the bazaar-commits
mailing list