summaryrefslogtreecommitdiffstats
path: root/Lib/multiprocessing
diff options
context:
space:
mode:
authorRichard Oudkerk <shibturn@gmail.com>2012-08-16 15:48:55 (GMT)
committerRichard Oudkerk <shibturn@gmail.com>2012-08-16 15:48:55 (GMT)
commit04ec8ce1bb394c0430d20ea3defa6282ac3e11cd (patch)
tree203399e1ecc98c7785d8b0fd4a4470053a90e3ca /Lib/multiprocessing
parent69a06dd59defa8de0586eb751b6acbed50fddc3e (diff)
downloadcpython-04ec8ce1bb394c0430d20ea3defa6282ac3e11cd.zip
cpython-04ec8ce1bb394c0430d20ea3defa6282ac3e11cd.tar.gz
cpython-04ec8ce1bb394c0430d20ea3defa6282ac3e11cd.tar.bz2
Issue #14669: Fix pickling of connections and sockets on MacOSX
by sending/receiving an acknowledgment after file descriptor transfer. TestPicklingConnection has been reenabled for MacOSX.
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r--Lib/multiprocessing/reduction.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/multiprocessing/reduction.py b/Lib/multiprocessing/reduction.py
index 84d2fe9..656fa8f 100644
--- a/Lib/multiprocessing/reduction.py
+++ b/Lib/multiprocessing/reduction.py
@@ -120,16 +120,24 @@ if sys.platform == 'win32':
else:
# Unix
+
+ # On MacOSX we should acknowledge receipt of fds -- see Issue14669
+ ACKNOWLEDGE = sys.platform == 'darwin'
+
def send_handle(conn, handle, destination_pid):
with socket.fromfd(conn.fileno(), socket.AF_UNIX, socket.SOCK_STREAM) as s:
s.sendmsg([b'x'], [(socket.SOL_SOCKET, socket.SCM_RIGHTS,
struct.pack("@i", handle))])
+ if ACKNOWLEDGE and conn.recv_bytes() != b'ACK':
+ raise RuntimeError('did not receive acknowledgement of fd')
def recv_handle(conn):
size = struct.calcsize("@i")
with socket.fromfd(conn.fileno(), socket.AF_UNIX, socket.SOCK_STREAM) as s:
msg, ancdata, flags, addr = s.recvmsg(1, socket.CMSG_LEN(size))
try:
+ if ACKNOWLEDGE:
+ conn.send_bytes(b'ACK')
cmsg_level, cmsg_type, cmsg_data = ancdata[0]
if (cmsg_level == socket.SOL_SOCKET and
cmsg_type == socket.SCM_RIGHTS):