[Python-checkins] bpo-34521: Fix tests in test_multiprocessing_spawn to use correctly CMSG_SPACE (GH-9613) (GH-9619)
Victor Stinner
webhook-mailer at python.org
Fri Sep 28 09:08:00 EDT 2018
https://github.com/python/cpython/commit/007fda436f707ac95c2fa8f8886efd9e09d5b630
commit: 007fda436f707ac95c2fa8f8886efd9e09d5b630
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Victor Stinner <vstinner at redhat.com>
date: 2018-09-28T06:07:56-07:00
summary:
bpo-34521: Fix tests in test_multiprocessing_spawn to use correctly CMSG_SPACE (GH-9613) (GH-9619)
After some failures in AMD64 FreeBSD CURRENT Debug 3.x buildbots
regarding tests in test_multiprocessing_spawn and after examining
similar failures in test_socket, some errors in the calculation of
ancillary data buffers were found in multiprocessing.reduction.
CMSG_LEN() can often be used as the buffer size for recvmsg() to
receive a single item of ancillary data, but RFC 3542 requires portable
applications to use CMSG_SPACE() and thus include space for padding,
even when the item will be the last in the buffer.
The failures we experience are due to the usage of CMSG_LEN() instead of
CMSG_SPACE().
(cherry picked from commit 077061a7b24917aaf31057885c69919c5a553c88)
Co-authored-by: Pablo Galindo <Pablogsal at gmail.com>
files:
M Lib/multiprocessing/reduction.py
diff --git a/Lib/multiprocessing/reduction.py b/Lib/multiprocessing/reduction.py
index deca19ccad7b..0f5432593a58 100644
--- a/Lib/multiprocessing/reduction.py
+++ b/Lib/multiprocessing/reduction.py
@@ -150,7 +150,7 @@ def recvfds(sock, size):
'''Receive an array of fds over an AF_UNIX socket.'''
a = array.array('i')
bytes_size = a.itemsize * size
- msg, ancdata, flags, addr = sock.recvmsg(1, socket.CMSG_LEN(bytes_size))
+ msg, ancdata, flags, addr = sock.recvmsg(1, socket.CMSG_SPACE(bytes_size))
if not msg and not ancdata:
raise EOFError
try:
More information about the Python-checkins
mailing list