mirror of
https://github.com/python/cpython.git
synced 2025-11-13 23:46:24 +00:00
Oops, move the GIL release/reacquire from oss_sync() to _do_ioctl_0():
that way it applies to *only* the ioctl() call, and also happens for the other blocking ioctls (POST, RESET).
This commit is contained in:
parent
7b4abbb2e2
commit
d0d592fd32
1 changed files with 11 additions and 7 deletions
|
|
@ -291,13 +291,22 @@ static PyObject *
|
||||||
_do_ioctl_0(int fd, PyObject *args, char *fname, int cmd)
|
_do_ioctl_0(int fd, PyObject *args, char *fname, int cmd)
|
||||||
{
|
{
|
||||||
char argfmt[32] = ":";
|
char argfmt[32] = ":";
|
||||||
|
int rv;
|
||||||
|
|
||||||
assert(strlen(fname) <= 30);
|
assert(strlen(fname) <= 30);
|
||||||
strcat(argfmt, fname);
|
strcat(argfmt, fname);
|
||||||
if (!PyArg_ParseTuple(args, argfmt))
|
if (!PyArg_ParseTuple(args, argfmt))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (ioctl(fd, cmd, 0) == -1)
|
/* According to hannu@opensound.com, all three of the ioctls that
|
||||||
|
use this function can block, so release the GIL. This is
|
||||||
|
especially important for SYNC, which can block for several
|
||||||
|
seconds. */
|
||||||
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
rv = ioctl(fd, cmd, 0);
|
||||||
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
|
if (rv == -1)
|
||||||
return PyErr_SetFromErrno(PyExc_IOError);
|
return PyErr_SetFromErrno(PyExc_IOError);
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
|
|
@ -353,12 +362,7 @@ oss_speed(oss_audio_t *self, PyObject *args)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
oss_sync(oss_audio_t *self, PyObject *args)
|
oss_sync(oss_audio_t *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int rv;
|
return _do_ioctl_0(self->fd, args, "sync", SNDCTL_DSP_SYNC);
|
||||||
|
|
||||||
Py_BEGIN_ALLOW_THREADS
|
|
||||||
rv = _do_ioctl_0(self->fd, args, "sync", SNDCTL_DSP_SYNC);
|
|
||||||
Py_END_ALLOW_THREADS
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue