4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-08 18:19:08 +08:00

Cygwin: AF_UNIX: recvmsg: support the MSG_TRUNC flag

This is in Linux since Linux 3.4 but not in Posix.

Not tested.
This commit is contained in:
Ken Brown 2020-10-29 11:39:00 -04:00
parent c69c850df4
commit d68d091944

View File

@ -2002,11 +2002,8 @@ fhandler_socket_unix::recvmsg (struct msghdr *msg, int flags)
__try
{
/* Valid flags: MSG_DONTWAIT, MSG_PEEK, MSG_WAITALL.
FIXME: Do we want to support MSG_TRUNC? It's not in POSIX,
but it's in Linux since 3.4. */
if (flags & ~(MSG_DONTWAIT | MSG_PEEK | MSG_WAITALL))
/* Valid flags: MSG_DONTWAIT, MSG_PEEK, MSG_WAITALL, MSG_TRUNC. */
if (flags & ~(MSG_DONTWAIT | MSG_PEEK | MSG_WAITALL | MSG_TRUNC))
{
set_errno (EOPNOTSUPP);
__leave;
@ -2428,7 +2425,9 @@ restart2:
/* For a datagram socket, truncate the data to what was requested. */
if (get_socket_type () == SOCK_DGRAM && tot < nbytes_read)
{
nbytes_now = nbytes_read = tot;
nbytes_now = tot;
if (!(flags & MSG_TRUNC))
nbytes_read = tot;
msg->msg_flags |= MSG_TRUNC;
}
/* Copy data to scatter-gather buffers. */