Message113384
Hi David
I have tried in another testbd with python 2.6.5, and the problem of hang doesn't reproduce, after retrying for several times.
The original hang happens in pipe.read of commands module.
After comparing the code of python 2.4.4 and python 2.6.5, I noticed two enhancements in posimodule.c:posix_read.
These defensive coding add precheck, before invoking read function.
David, without these enhancements, would it cause the potential hang problem, in your opinion?
Recompiling python 2.4.4 with some manual changes is a little scaring to me.
,----------- python 2.4.4 posixmodule.c
| static PyObject *
| posix_read(PyObject *self, PyObject *args)
| {
| int fd, size, n;
| PyObject *buffer;
| if (!PyArg_ParseTuple(args, "ii:read", &fd, &size))
| return NULL;
| buffer = PyString_FromStringAndSize((char *)NULL, size);
| if (buffer == NULL)
| return NULL;
| Py_BEGIN_ALLOW_THREADS
| n = read(fd, PyString_AsString(buffer), size);
| Py_END_ALLOW_THREADS
| if (n < 0) {
| Py_DECREF(buffer);
| return posix_error();
| }
| if (n != size)
| _PyString_Resize(&buffer, n);
| return buffer;
| }
`-----------
,----------- 2.6.5 posixmodule.c
| static PyObject *
| posix_read(PyObject *self, PyObject *args)
| {
| int fd, size, n;
| PyObject *buffer;
| if (!PyArg_ParseTuple(args, "ii:read", &fd, &size))
| return NULL;
| if (size < 0) {
| errno = EINVAL;
| return posix_error();
| }
| buffer = PyString_FromStringAndSize((char *)NULL, size);
| if (buffer == NULL)
| return NULL;
| if (!_PyVerify_fd(fd))
| return posix_error();
| Py_BEGIN_ALLOW_THREADS
| n = read(fd, PyString_AsString(buffer), size);
| Py_END_ALLOW_THREADS
| if (n < 0) {
| Py_DECREF(buffer);
| return posix_error();
| }
| if (n != size)
| _PyString_Resize(&buffer, n);
| return buffer;
| }
`----------- |
|
Date |
User |
Action |
Args |
2010-08-09 05:16:23 | denny | set | recipients:
+ denny, r.david.murray |
2010-08-09 05:16:23 | denny | set | messageid: <1281330983.3.0.486559668665.issue9532@psf.upfronthosting.co.za> |
2010-08-09 05:16:21 | denny | link | issue9532 messages |
2010-08-09 05:16:20 | denny | create | |
|