Commit 433631e4 authored by Antoine Pitrou's avatar Antoine Pitrou

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.
........
parent 6af9201c
...@@ -225,6 +225,9 @@ Library ...@@ -225,6 +225,9 @@ Library
Extension Modules Extension Modules
----------------- -----------------
- Issue #7736: Release the GIL around calls to opendir() and closedir()
in the posix module. Patch by Marcin Bachry.
- As a result of issue #2521, the _weakref module is now compiled into the - As a result of issue #2521, the _weakref module is now compiled into the
interpreter by default. interpreter by default.
......
...@@ -2333,11 +2333,16 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -2333,11 +2333,16 @@ posix_listdir(PyObject *self, PyObject *args)
} }
if (!PyArg_ParseTuple(args, "et:listdir", Py_FileSystemDefaultEncoding, &name)) if (!PyArg_ParseTuple(args, "et:listdir", Py_FileSystemDefaultEncoding, &name))
return NULL; return NULL;
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(name); return posix_error_with_allocated_filename(name);
} }
if ((d = PyList_New(0)) == NULL) { if ((d = PyList_New(0)) == NULL) {
Py_BEGIN_ALLOW_THREADS
closedir(dirp); closedir(dirp);
Py_END_ALLOW_THREADS
PyMem_Free(name); PyMem_Free(name);
return NULL; return NULL;
} }
...@@ -2350,7 +2355,9 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -2350,7 +2355,9 @@ posix_listdir(PyObject *self, PyObject *args)
if (errno == 0) { if (errno == 0) {
break; break;
} else { } else {
Py_BEGIN_ALLOW_THREADS
closedir(dirp); closedir(dirp);
Py_END_ALLOW_THREADS
Py_DECREF(d); Py_DECREF(d);
return posix_error_with_allocated_filename(name); return posix_error_with_allocated_filename(name);
} }
...@@ -2391,7 +2398,9 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -2391,7 +2398,9 @@ posix_listdir(PyObject *self, PyObject *args)
} }
Py_DECREF(v); Py_DECREF(v);
} }
Py_BEGIN_ALLOW_THREADS
closedir(dirp); closedir(dirp);
Py_END_ALLOW_THREADS
PyMem_Free(name); PyMem_Free(name);
return d; return d;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment