summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-09-04 17:26:01 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-09-04 17:26:01 (GMT)
commit037077fe0362bfddd4a7723674ef39e8dcf1934a (patch)
tree27aa42ca01de2ad637e95ee26068f9e46076772f
parent8f94754d3ab6e9b27932a5f870f3500ca8e3ed84 (diff)
downloadcpython-037077fe0362bfddd4a7723674ef39e8dcf1934a.zip
cpython-037077fe0362bfddd4a7723674ef39e8dcf1934a.tar.gz
cpython-037077fe0362bfddd4a7723674ef39e8dcf1934a.tar.bz2
Merged revisions 84489 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r84489 | antoine.pitrou | 2010-09-04 19:21:57 +0200 (sam., 04 sept. 2010) | 4 lines Issue #7736: Release the GIL around calls to opendir() and closedir() in the posix module. Patch by Marcin Bachry. ........
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/posixmodule.c11
2 files changed, 13 insertions, 1 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index bec7771..b5c4725 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -474,6 +474,9 @@ Library
Extension Modules
-----------------
+- Issue #7736: Release the GIL around calls to opendir() and closedir()
+ in the posix module. Patch by Marcin Bachry.
+
- Issue #4835: make PyLong_FromSocket_t() and PyLong_AsSocket_t() private
to the socket module, and fix the width of socket descriptors to be
correctly detected under 64-bit Windows.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 5a5badd..ed2447b 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2493,11 +2493,16 @@ posix_listdir(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O&:listdir", PyUnicode_FSConverter, &oname))
return NULL;
name = bytes2str(oname, 1);
- if ((dirp = opendir(name)) == NULL) {
+ Py_BEGIN_ALLOW_THREADS
+ dirp = opendir(name);
+ Py_END_ALLOW_THREADS
+ if (dirp == NULL) {
return posix_error_with_allocated_filename(oname);
}
if ((d = PyList_New(0)) == NULL) {
+ Py_BEGIN_ALLOW_THREADS
closedir(dirp);
+ Py_END_ALLOW_THREADS
release_bytes(oname);
return NULL;
}
@@ -2510,7 +2515,9 @@ posix_listdir(PyObject *self, PyObject *args)
if (errno == 0) {
break;
} else {
+ Py_BEGIN_ALLOW_THREADS
closedir(dirp);
+ Py_END_ALLOW_THREADS
Py_DECREF(d);
return posix_error_with_allocated_filename(oname);
}
@@ -2550,7 +2557,9 @@ posix_listdir(PyObject *self, PyObject *args)
}
Py_DECREF(v);
}
+ Py_BEGIN_ALLOW_THREADS
closedir(dirp);
+ Py_END_ALLOW_THREADS
release_bytes(oname);
return d;