]> granicus.if.org Git - python/commitdiff
Issue #7736: Release the GIL around calls to opendir() and closedir()
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 4 Sep 2010 17:21:57 +0000 (17:21 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 4 Sep 2010 17:21:57 +0000 (17:21 +0000)
in the posix module.  Patch by Marcin Bachry.

Misc/NEWS
Modules/posixmodule.c

index bf907a5be2e7ece5b30059b42af5083c1ebeaf3e..1433598749d9deaefc61ab496b02f94c9a6ae160 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -93,6 +93,9 @@ Core and Builtins
 Extensions
 ----------
 
+- 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.
index ce625b4b54b869c66fd9315afee9653494c74dbe..1080c7e07142da5888990fdfdaa2cb6e549e75cc 100644 (file)
@@ -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;