summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2003-05-23 01:50:37 (GMT)
committerGreg Ward <gward@python.net>2003-05-23 01:50:37 (GMT)
commit6492785ee521f3d46a07c07e96a7bc3d72b54f38 (patch)
tree51e2e7961a3942b2f25dc945c07f5a5486525ed4 /Modules
parenta1d654e13a1c8f658a1f0a04dafec8005e241a99 (diff)
downloadcpython-6492785ee521f3d46a07c07e96a7bc3d72b54f38.zip
cpython-6492785ee521f3d46a07c07e96a7bc3d72b54f38.tar.gz
cpython-6492785ee521f3d46a07c07e96a7bc3d72b54f38.tar.bz2
Release the GIL around read(), write(), and select() calls.
Bug spotted by Joerg Lehmann <joerg@luga.de>.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/ossaudiodev.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c
index 948ffe7..6196d36 100644
--- a/Modules/ossaudiodev.c
+++ b/Modules/ossaudiodev.c
@@ -385,7 +385,12 @@ oss_read(oss_audio_t *self, PyObject *args)
if (rv == NULL)
return NULL;
cp = PyString_AS_STRING(rv);
- if ((count = read(self->fd, cp, size)) < 0) {
+
+ Py_BEGIN_ALLOW_THREADS
+ count = read(self->fd, cp, size);
+ Py_END_ALLOW_THREADS
+
+ if (count < 0) {
PyErr_SetFromErrno(PyExc_IOError);
Py_DECREF(rv);
return NULL;
@@ -404,7 +409,12 @@ oss_write(oss_audio_t *self, PyObject *args)
if (!PyArg_ParseTuple(args, "s#:write", &cp, &size)) {
return NULL;
}
- if ((rv = write(self->fd, cp, size)) == -1) {
+
+ Py_BEGIN_ALLOW_THREADS
+ rv = write(self->fd, cp, size);
+ Py_END_ALLOW_THREADS
+
+ if (rv == -1) {
return PyErr_SetFromErrno(PyExc_IOError);
} else {
self->ocount += rv;
@@ -435,12 +445,16 @@ oss_writeall(oss_audio_t *self, PyObject *args)
FD_SET(self->fd, &write_set_fds);
while (size > 0) {
+ Py_BEGIN_ALLOW_THREADS
select_rv = select(self->fd+1, NULL, &write_set_fds, NULL, NULL);
+ Py_END_ALLOW_THREADS
assert(select_rv != 0); /* no timeout, can't expire */
if (select_rv == -1)
return PyErr_SetFromErrno(PyExc_IOError);
+ Py_BEGIN_ALLOW_THREADS
rv = write(self->fd, cp, size);
+ Py_END_ALLOW_THREADS
if (rv == -1) {
if (errno == EAGAIN) { /* buffer is full, try again */
errno = 0;