[newlib-cygwin] Cygwin: define MSG_EOR and refuse in send(2)

Corinna Vinschen corinna@sourceware.org
Thu Apr 25 17:00:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f527171a9395f316889e0e2b12fffac14bdf98c4

commit f527171a9395f316889e0e2b12fffac14bdf98c4
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Thu Apr 25 18:49:32 2019 +0200

    Cygwin: define MSG_EOR and refuse in send(2)
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler_socket_inet.cc | 7 +++++++
 winsup/cygwin/include/cygwin/socket.h | 2 ++
 winsup/cygwin/release/3.1.0           | 4 ++++
 3 files changed, 13 insertions(+)

diff --git a/winsup/cygwin/fhandler_socket_inet.cc b/winsup/cygwin/fhandler_socket_inet.cc
index 46af1c4..6f43838 100644
--- a/winsup/cygwin/fhandler_socket_inet.cc
+++ b/winsup/cygwin/fhandler_socket_inet.cc
@@ -1351,6 +1351,13 @@ fhandler_socket_wsock::send_internal (struct _WSAMSG *wsamsg, int flags)
   DWORD wait_flags = flags & MSG_DONTWAIT;
   bool nosignal = !!(flags & MSG_NOSIGNAL);
 
+  /* MSG_EOR not supported by any protocol */
+  if (flags & MSG_EOR)
+    {
+      set_errno (EOPNOTSUPP);
+      return SOCKET_ERROR;
+    }
+
   flags &= (MSG_OOB | MSG_DONTROUTE);
   if (wsamsg->Control.len > 0)
     use_sendmsg = true;
diff --git a/winsup/cygwin/include/cygwin/socket.h b/winsup/cygwin/include/cygwin/socket.h
index 77d87ff..cdfa4b9 100644
--- a/winsup/cygwin/include/cygwin/socket.h
+++ b/winsup/cygwin/include/cygwin/socket.h
@@ -207,6 +207,8 @@ struct OLD_msghdr
 /* AF_UNIX specific */
 #define MSG_CMSG_CLOEXEC 0x1000		/* Set O_CLOEXEC on fd's passed via
 					   SCM_RIGHTS */
+/* MSG_EOR is not supported.  We use the MSG_PARTIAL flag here */
+#define MSG_EOR		0x8000		/* Terminates a record */
 
 /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
 #define SOL_IP		0
diff --git a/winsup/cygwin/release/3.1.0 b/winsup/cygwin/release/3.1.0
index 95569fc..fe65e50 100644
--- a/winsup/cygwin/release/3.1.0
+++ b/winsup/cygwin/release/3.1.0
@@ -24,3 +24,7 @@ Bug Fixes
   completed, instead of when only one key is typed.
 
 - Make console I/O functions thread-safe.
+
+- Define missing MSG_EOR.  It's unsupported by the underlying Winsock
+  layer so using it in send(2), sendto(2), or sendmsg(2) will return -1
+  with errno set to EOPNOTSUPP and recvmsg(2) will never return it.



More information about the Cygwin-cvs mailing list