[Python-checkins] bpo-34521: Fix FD transfer in multiprocessing on FreeBSD (GH-15422)

Victor Stinner webhook-mailer at python.org
Fri Aug 23 09:00:42 EDT 2019


https://github.com/python/cpython/commit/c3642219090f2564c1790330cbf0ba31f19dcaf4
commit: c3642219090f2564c1790330cbf0ba31f19dcaf4
branch: 2.7
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2019-08-23T14:00:38+01:00
summary:

bpo-34521: Fix FD transfer in multiprocessing on FreeBSD (GH-15422)

Fix file descriptors transfer in multiprocessing on FreeBSD: use
CMSG_SPACE() rather than CMSG_LEN(); see RFC 3542.

files:
A Misc/NEWS.d/next/Library/2019-08-23-14-47-09.bpo-34521.Y2BYu5.rst
M Modules/_multiprocessing/multiprocessing.c

diff --git a/Misc/NEWS.d/next/Library/2019-08-23-14-47-09.bpo-34521.Y2BYu5.rst b/Misc/NEWS.d/next/Library/2019-08-23-14-47-09.bpo-34521.Y2BYu5.rst
new file mode 100644
index 000000000000..06f42a841ea1
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-08-23-14-47-09.bpo-34521.Y2BYu5.rst
@@ -0,0 +1,2 @@
+Fix file descriptors transfer in multiprocessing on FreeBSD: use
+``CMSG_SPACE()`` rather than ``CMSG_LEN()``; see :rfc:`3542`.
diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c
index d192a074ba55..eecace887e62 100644
--- a/Modules/_multiprocessing/multiprocessing.c
+++ b/Modules/_multiprocessing/multiprocessing.c
@@ -167,7 +167,7 @@ multiprocessing_recvfd(PyObject *self, PyObject *args)
     cmsg = CMSG_FIRSTHDR(&msg);
     cmsg->cmsg_level = SOL_SOCKET;
     cmsg->cmsg_type = SCM_RIGHTS;
-    cmsg->cmsg_len = CMSG_LEN(sizeof(int));
+    cmsg->cmsg_len = CMSG_SPACE(sizeof(int));
     msg.msg_controllen = cmsg->cmsg_len;
 
     Py_BEGIN_ALLOW_THREADS



More information about the Python-checkins mailing list