From fd10bdc12e14a7853b077f8fb1e31d72f9aa5788 Mon Sep 17 00:00:00 2001 From: Johan Pelo Date: Wed, 19 Jun 2024 07:10:12 +0200 Subject: [PATCH] Turn off PACKET_DESTINATION_INFO for mingw-w64. The CMSG_* macros used in CycloneDDS are not provided by mingw-w64-gcc (only WSA*). Set the number of bytes received also for nonzero return from wsarecvmsg. Closes #2027 --- src/core/ddsi/src/ddsi_udp.c | 3 +++ src/ddsrt/src/sockets/windows/socket.c | 1 + 2 files changed, 4 insertions(+) diff --git a/src/core/ddsi/src/ddsi_udp.c b/src/core/ddsi/src/ddsi_udp.c index 5efd60b4a1..b723d83ad9 100644 --- a/src/core/ddsi/src/ddsi_udp.c +++ b/src/core/ddsi/src/ddsi_udp.c @@ -49,6 +49,9 @@ DDSRT_STATIC_ASSERT (DDSI_LOCATOR_UDPv4MCGEN_INDEX_MASK_BITS <= 32 - UDP_MC_ADDR # endif #endif #ifndef PACKET_DESTINATION_INFO +# if defined (__MINGW32__) && !defined (CMSG_SPACE) +# define PACKET_DESTINATION_INFO 0 +# endif # if defined CMSG_SPACE && (defined IP_PKTINFO || (DDSRT_HAVE_IPV6 && defined IPV6_PKTINFO)) # define PACKET_DESTINATION_INFO 1 # else diff --git a/src/ddsrt/src/sockets/windows/socket.c b/src/ddsrt/src/sockets/windows/socket.c index a875d18f03..cf80213564 100644 --- a/src/ddsrt/src/sockets/windows/socket.c +++ b/src/ddsrt/src/sockets/windows/socket.c @@ -570,6 +570,7 @@ ddsrt_recvmsg( if (sockext->wsarecvmsg (sockext->sock, &wsamsg, &n, NULL, 0) != 0) { int err = WSAGetLastError(); + *rcvd = (ssize_t) n; return recv_error_to_retcode(err); } else