summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-09-04 17:21:57 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-09-04 17:21:57 (GMT)
commitd3ccde8a21755046cdb3f73fb11e46d1043dc076 (patch)
tree628e3fdf6d4c2cabf62a7d9bf1ebefd49ca6f697 /Modules/posixmodule.c
parent327fd40dde2a22fd1162dfda64bc6c8c96552b71 (diff)
downloadcpython-d3ccde8a21755046cdb3f73fb11e46d1043dc076.zip
cpython-d3ccde8a21755046cdb3f73fb11e46d1043dc076.tar.gz
cpython-d3ccde8a21755046cdb3f73fb11e46d1043dc076.tar.bz2
Issue #7736: Release the GIL around calls to opendir() and closedir()
in the posix module. Patch by Marcin Bachry.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index ce625b4..1080c7e 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -2580,11 +2580,16 @@ posix_listdir(PyObject *self, PyObject *args)
oname = PyBytes_FromString(".");
}
name = PyBytes_AsString(oname);
- 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
Py_DECREF(oname);
return NULL;
}
@@ -2597,7 +2602,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);
}
@@ -2621,7 +2628,9 @@ posix_listdir(PyObject *self, PyObject *args)
}
Py_DECREF(v);
}
+ Py_BEGIN_ALLOW_THREADS
closedir(dirp);
+ Py_END_ALLOW_THREADS
Py_DECREF(oname);
return d;