Commit 9f036b87 authored by Alexey Borzenkov's avatar Alexey Borzenkov

Don't ensure GIL in vfd_open() and vfd_free() when called from Python

parent eef1eeaf
...@@ -75,7 +75,9 @@ static int vfd_open_(long handle, int pyexc) ...@@ -75,7 +75,9 @@ static int vfd_open_(long handle, int pyexc)
PyObject* key = NULL; PyObject* key = NULL;
PyObject* value; PyObject* value;
VFD_GIL_ENSURE; if (!pyexc) {
VFD_GIL_ENSURE;
}
if (ioctlsocket(handle, FIONREAD, &arg) != 0) { if (ioctlsocket(handle, FIONREAD, &arg) != 0) {
if (pyexc) if (pyexc)
PyErr_Format(PyExc_IOError, "%ld is not a socket (files are not supported)", handle); PyErr_Format(PyExc_IOError, "%ld is not a socket (files are not supported)", handle);
...@@ -136,7 +138,9 @@ allocated: ...@@ -136,7 +138,9 @@ allocated:
Py_DECREF(value); Py_DECREF(value);
done: done:
Py_XDECREF(key); Py_XDECREF(key);
VFD_GIL_RELEASE; if (!pyexc) {
VFD_GIL_RELEASE;
}
return fd; return fd;
} }
...@@ -148,7 +152,9 @@ static void vfd_free_(int fd, int needclose) ...@@ -148,7 +152,9 @@ static void vfd_free_(int fd, int needclose)
VFD_GIL_DECLARE; VFD_GIL_DECLARE;
PyObject* key; PyObject* key;
VFD_GIL_ENSURE; if (needclose) {
VFD_GIL_ENSURE;
}
if (fd < 0 || fd >= vfd_num) if (fd < 0 || fd >= vfd_num)
goto done; /* out of bounds */ goto done; /* out of bounds */
if (vfd_entries[fd].count <= 0) if (vfd_entries[fd].count <= 0)
...@@ -167,7 +173,9 @@ static void vfd_free_(int fd, int needclose) ...@@ -167,7 +173,9 @@ static void vfd_free_(int fd, int needclose)
Py_DECREF(key); Py_DECREF(key);
} }
done: done:
VFD_GIL_RELEASE; if (needclose) {
VFD_GIL_RELEASE;
}
} }
#define vfd_free(fd) vfd_free_((fd), 0) #define vfd_free(fd) vfd_free_((fd), 0)
......
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