Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
PyPy
pypy
Commits
451ff45aeccb
Commit
d7cfcddc
authored
Dec 03, 2022
by
Carl Friedrich Bolz-Tereick
Browse files
#3864
fix MSG_TRUNC socket weirdness on linux
--HG-- branch : release-pypy2.7-v7.x
parent
e49f9f3c0e72
Pipeline
#59197
passed with stage
in 5 minutes and 51 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
rpython/rlib/rsocket.py
View file @
451ff45a
...
...
@@ -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
):
...
...
rpython/rlib/test/test_rsocket.py
View file @
451ff45a
...
...
@@ -774,3 +774,12 @@ def test_sethostname():
with
pytest
.
raises
(
CSocketError
)
as
e
:
sethostname
(
s
)
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
)
a
.
send
(
b
'abcdefgh'
)
result
=
b
.
recv
(
2
,
socket
.
MSG_TRUNC
)
assert
result
==
b
'ab'
Matti Picus
@mattip
mentioned in commit
a702b2c7e76f
·
Dec 06, 2022
mentioned in commit
a702b2c7e76f
mentioned in commit f0df5ef173e82e84d7c3672eca9f83983f6c06d0
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment