Commit d7cfcddc authored by Carl Friedrich Bolz-Tereick's avatar Carl Friedrich Bolz-Tereick
Browse files

#3864 fix MSG_TRUNC socket weirdness on linux

branch : release-pypy2.7-v7.x
parent e49f9f3c0e72
Pipeline #59197 passed with stage
in 5 minutes and 51 seconds
......@@ -917,6 +917,10 @@ class RSocket(object):
with rffi.scoped_alloc_buffer(buffersize) as buf:
llbuf = LLBuffer(buf.raw, buffersize)
read_bytes = self.recvinto(llbuf, buffersize, flags)
if _c.linux and flags & _c.MSG_TRUNC and read_bytes > buffersize:
# on linux, if MSG_TRUNC is given, read_bytes is the size of
# the packet, not the amounts of bytes written into buf
read_bytes = buffersize
return buf.str(read_bytes)
def recvinto(self, rwbuffer, nbytes, flags=0):
......@@ -774,3 +774,12 @@ def test_sethostname():
with pytest.raises(CSocketError) as e:
assert e.value.errno == errno.EPERM
@pytest.mark.skipif(sys.platform == "linux",
reason='this behaviour of MSG_TRUNC is linux specific')
def test_msg_trunc_weirdness_linux():
import socket
(a, b) = socketpair(rsocket.AF_UNIX, rsocket.SOCK_DGRAM)
result = b.recv(2, socket.MSG_TRUNC)
assert result == b'ab'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment