Skip to content

Conversation

@miccoli
Copy link

@miccoli miccoli commented Aug 21, 2023

This PR extends the test suite for failing due to gh-107898, and implements the trivial fixes in Lib/socket.py.

New checks:

  • MSG_PEEK flag in socket.recv_fds
  • using unconnected SOCK_DGRAM sockets with the address parameter is socket.send_fds

A minor correction is done to the docs.


📚 Documentation preview 📚: https://cpython-previews--108243.org.readthedocs.build/

Class SendRecvFdsTests is refactored to test also the optional
parameters of recv_fds and send_fds.
Methods
- testSendAndRecvFds: base check, semantically equivalent to legacy
  version, changes are only for legibility and code reuse in following
  tests.
- testRecvFlags: new test in which the socket.MSG_PEEK flag is passed
  to recv_fds. socket.MSG_PEEK semantics is checked.
- testSendAddress: new test in which the address parameter of send_fds
  is tested on a connectionless socket of type SOCK_DGRAM

There are no tests for the flags of send_fds, because testing MSG_OOB
would be way too complicated.
…ecv_fds

Optional parameters (flags and adress) are passed to undelying
sendmsg and recvmsg functions.

Minor code formatting for legibility.
An inconclusive sentence is dropped: the code should be able to
handle truncated integers at the end of cmsg_data, no need to
alert the user.
@ghost
Copy link

ghost commented Aug 21, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

When receiving fds with the MSG_PEEK flag, two cases may arise.

1. The incoming msg has msg_flags == 0 and ancillary data contains open fd's
   (seen on linux);
2. msg_flags == MSG_PEEK and ancillary data contains a null array
   (seen on darwin).
@miccoli
Copy link
Author

miccoli commented Aug 22, 2023

Sorry for the messy PR... I should have tested also in a linux container and not only on macOS.

This is my first PR in cpython, please let me know if I should rebase and force-push or leave it with the many attemps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants