cpython: 60a7b704de5c (original) (raw)
Mercurial > cpython
changeset 77408:60a7b704de5c 2.7
Issue #10133: Make multiprocessing deallocate buffer if socket read fails. Patch by Hallvard B Furuseth. [#10133]
Richard Oudkerk shibturn@gmail.com | |
---|---|
date | Mon, 11 Jun 2012 15:11:35 +0100 |
parents | 272e7dcffd30 |
children | 744fb52ffdf0 |
files | Misc/NEWS Modules/_multiprocessing/socket_connection.c |
diffstat | 2 files changed, 19 insertions(+), 13 deletions(-)[+] [-] Misc/NEWS 3 Modules/_multiprocessing/socket_connection.c 29 |
line wrap: on
line diff
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -67,6 +67,9 @@ Core and Builtins Library ------- +- Issue #10133: Make multiprocessing deallocate buffer if socket read
--- a/Modules/_multiprocessing/socket_connection.c +++ b/Modules/_multiprocessing/socket_connection.c @@ -117,7 +117,7 @@ static Py_ssize_t conn_recv_string(ConnectionObject *conn, char *buffer, size_t buflength, char **newbuffer, size_t maxlength) {
- Py_ssize_t res; UINT32 ulength; *newbuffer = NULL; @@ -132,20 +132,23 @@ conn_recv_string(ConnectionObject *conn, if (ulength > maxlength) return MP_BAD_MESSAGE_LENGTH;
- if (ulength <= buflength) {
Py_BEGIN_ALLOW_THREADS[](#l2.17)
res = _conn_recvall(conn->handle, buffer, (size_t)ulength);[](#l2.18)
Py_END_ALLOW_THREADS[](#l2.19)
return res < 0 ? res : ulength;[](#l2.20)
- } else {
*newbuffer = PyMem_Malloc((size_t)ulength);[](#l2.22)
if (*newbuffer == NULL)[](#l2.23)
- if (ulength > buflength) {
*newbuffer = buffer = PyMem_Malloc((size_t)ulength);[](#l2.25)
if (buffer == NULL)[](#l2.26) return MP_MEMORY_ERROR;[](#l2.27)
Py_BEGIN_ALLOW_THREADS[](#l2.28)
res = _conn_recvall(conn->handle, *newbuffer, (size_t)ulength);[](#l2.29)
Py_END_ALLOW_THREADS[](#l2.30)
} +return res < 0 ? (Py_ssize_t)res : (Py_ssize_t)ulength;[](#l2.31)
- Py_BEGIN_ALLOW_THREADS
- res = _conn_recvall(conn->handle, buffer, (size_t)ulength);
- Py_END_ALLOW_THREADS