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.
This commit is contained in:
Victor Stinner 2019-08-23 14:00:38 +01:00 committed by GitHub
parent 3b26f734c0
commit c364221909
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -0,0 +1,2 @@
Fix file descriptors transfer in multiprocessing on FreeBSD: use
``CMSG_SPACE()`` rather than ``CMSG_LEN()``; see :rfc:`3542`.

View File

@ -167,7 +167,7 @@ multiprocessing_recvfd(PyObject *self, PyObject *args)
cmsg = CMSG_FIRSTHDR(&msg); cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS; 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; msg.msg_controllen = cmsg->cmsg_len;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS