Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mingw-w64 + improve ddsrt_recvmsg interface #2053

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

eboasson
Copy link
Contributor

@eboasson eboasson commented Jul 1, 2024

This takes the change for PACKET_DESTINATION_INFO from #2045 and bundles it with an improvement to the interface of ddsrt_recvmsg.

Closes #2027

There is only one caller of ddsrt_recvmsg (outside the tests), ddsi_udp_conn_read, and it
assumed that ddsrt_recvmsg:

1. returns OK with *rcvd > 0
2. returns OK with *rcvd = 0
3. returns not-OK with *rcvd untouched or set to 0

Case 1 is the perfectly ordinary case.

Case 2 is treated as a spurious but successful read.  This is somewhat weird: the socket
triggers because data is available and so a read should return something.  IIRC it is
there because with OpenSSL 3 and TCP+TLS I saw received bytes all getting consumed
internally by OpenSSL during a handshake.  Anyway, it exists.

Case 3 is for all errors.  The "*rcvd untouched or set to 0" was important because
ddsi_udp_conn_read would first check whether it is > 0.  It initializes it to 0, so if it
is untouched on error or set to 0, all is well.

The one caller of ddsi_udp_conn_read is ddsi_receive.c:do_packet, which simply ignores any
call to ddsi_udp_conn_read that returns <= 0.  So case 2 can be propagated by returning
0 (successful spurious read) or < 0 (error) without any difference in behaviour.

This requirement on *rcvd in case of an error is an accident waiting to happen.  This
commit changes the interface so that it is:

1. OK and *rcvd >= 0
2. not-OK and *rcvd undefined

This requires no changes on the implementation of ddsrt_recvmsg.  The change in the
caller is trivial and makes it as one would expect.

Signed-off-by: Erik Boasson <[email protected]>
The CMSG_* macros used in CycloneDDS are not provided by mingw-w64-gcc (only WSA*).

Signed-off-by: Erik Boasson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HelloWorld example broken on master with MinGW/ucrt64
1 participant