diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-08-09 23:39:31 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-08-09 23:39:31 (GMT) |
commit | b73caab4362e38e4a55af6a04fe0740b3c67cf69 (patch) | |
tree | d6050f09f60ad844433decd4483b2e5112405330 /Modules | |
parent | 5af4f4b9832411476caf8cf3f571f974056d4f1b (diff) | |
download | cpython-b73caab4362e38e4a55af6a04fe0740b3c67cf69.zip cpython-b73caab4362e38e4a55af6a04fe0740b3c67cf69.tar.gz cpython-b73caab4362e38e4a55af6a04fe0740b3c67cf69.tar.bz2 |
Issue #6915: Under Windows, os.listdir() didn't release the Global
Interpreter Lock around all system calls. Original patch by Ryan Kelly.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/posixmodule.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 0b14f5c..449093a 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1229,7 +1229,7 @@ win32_stat_w(const wchar_t* path, struct win32_stat *result) /* FILE_FLAG_BACKUP_SEMANTICS is required to open a directory */ FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS, NULL); - + if(hFile == INVALID_HANDLE_VALUE) { /* Either the target doesn't exist, or we don't have access to get a handle to it. If the former, we need to return an error. @@ -2353,7 +2353,9 @@ posix_listdir(PyObject *self, PyObject *args) free(wnamebuf); return NULL; } + Py_BEGIN_ALLOW_THREADS hFindFile = FindFirstFileW(wnamebuf, &wFileData); + Py_END_ALLOW_THREADS if (hFindFile == INVALID_HANDLE_VALUE) { int error = GetLastError(); if (error == ERROR_FILE_NOT_FOUND) { @@ -2430,7 +2432,9 @@ posix_listdir(PyObject *self, PyObject *args) if ((d = PyList_New(0)) == NULL) return NULL; + Py_BEGIN_ALLOW_THREADS hFindFile = FindFirstFile(namebuf, &FileData); + Py_END_ALLOW_THREADS if (hFindFile == INVALID_HANDLE_VALUE) { int error = GetLastError(); if (error == ERROR_FILE_NOT_FOUND) |