This is the mail archive of the cygwin-cvs@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[newlib-cygwin] Cygwin: make socketpair an AF_LOCAL-only method


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

commit 84c5e0fd3dd263e1e59076e88e65998865d1d9cd
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Thu Feb 22 16:25:28 2018 +0100

    Cygwin: make socketpair an AF_LOCAL-only method
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler.h               |  6 +-----
 winsup/cygwin/fhandler_socket_inet.cc  | 10 ----------
 winsup/cygwin/fhandler_socket_local.cc |  3 +--
 winsup/cygwin/net.cc                   | 18 +++---------------
 4 files changed, 5 insertions(+), 32 deletions(-)

diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index c50667c..4b1d8dd 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -574,8 +574,6 @@ class fhandler_socket: public fhandler_base
   IMPLEMENT_STATUS_FLAG (bool, no_getpeereid)
 
   virtual int socket (int af, int type, int protocol, int flags) = 0;
-  virtual int socketpair (int af, int type, int protocol, int flags,
-			  fhandler_socket *fh_out) = 0;
   virtual int bind (const struct sockaddr *name, int namelen) = 0;
   virtual int listen (int backlog) = 0;
   virtual int accept4 (struct sockaddr *peer, int *len, int flags) = 0;
@@ -650,8 +648,6 @@ class fhandler_socket_inet: public fhandler_socket
   ~fhandler_socket_inet ();
 
   int socket (int af, int type, int protocol, int flags);
-  int socketpair (int af, int type, int protocol, int flags,
-		  fhandler_socket *fh_out);
   int bind (const struct sockaddr *name, int namelen);
   int listen (int backlog);
   int accept4 (struct sockaddr *peer, int *len, int flags);
@@ -736,7 +732,7 @@ class fhandler_socket_local: public fhandler_socket
 
   int socket (int af, int type, int protocol, int flags);
   int socketpair (int af, int type, int protocol, int flags,
-		  fhandler_socket *fh_out);
+		  fhandler_socket_local *fh_out);
   int bind (const struct sockaddr *name, int namelen);
   int listen (int backlog);
   int accept4 (struct sockaddr *peer, int *len, int flags);
diff --git a/winsup/cygwin/fhandler_socket_inet.cc b/winsup/cygwin/fhandler_socket_inet.cc
index a161050..0609197 100644
--- a/winsup/cygwin/fhandler_socket_inet.cc
+++ b/winsup/cygwin/fhandler_socket_inet.cc
@@ -136,16 +136,6 @@ fhandler_socket_inet::socket (int af, int type, int protocol, int flags)
   return ret;
 }
 
-/* socketpair is called on the fhandler handling the accepting socket,
-   fh_out is the fhandler for the connecting socket. */
-int
-fhandler_socket_inet::socketpair (int af, int type, int protocol, int flags,
-				  fhandler_socket *fh_out)
-{
-  set_errno (EAFNOSUPPORT);
-  return -1;
-}
-
 int
 fhandler_socket_inet::bind (const struct sockaddr *name, int namelen)
 {
diff --git a/winsup/cygwin/fhandler_socket_local.cc b/winsup/cygwin/fhandler_socket_local.cc
index ca1fe5e..c5e4bfb 100644
--- a/winsup/cygwin/fhandler_socket_local.cc
+++ b/winsup/cygwin/fhandler_socket_local.cc
@@ -241,7 +241,7 @@ fhandler_socket_local::socket (int af, int type, int protocol, int flags)
 
 int
 fhandler_socket_local::socketpair (int af, int type, int protocol, int flags,
-				   fhandler_socket *_fh_out)
+				   fhandler_socket_local *fh_out)
 {
   SOCKET insock = INVALID_SOCKET;
   SOCKET outsock = INVALID_SOCKET;
@@ -249,7 +249,6 @@ fhandler_socket_local::socketpair (int af, int type, int protocol, int flags,
   struct sockaddr_in sock_in, sock_out;
   int len;
 
- fhandler_socket_local *fh_out = (fhandler_socket_local *) _fh_out;
   /* create listening socket */
   sock = ::socket (AF_INET, type, 0);
   if (sock == INVALID_SOCKET)
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index e849b04..7c58b91 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -2303,7 +2303,7 @@ socketpair (int af, int type, int protocol, int *sb)
 {
   int res = -1;
   const device *dev;
-  fhandler_socket *fh_in, *fh_out;
+  fhandler_socket_local *fh_in, *fh_out;
 
   int flags = type & _SOCK_FLAG_MASK;
   type &= ~_SOCK_FLAG_MASK;
@@ -2325,18 +2325,6 @@ socketpair (int af, int type, int protocol, int *sb)
         }
       dev = type == SOCK_STREAM ? stream_dev : dgram_dev;
       break;
-#if 0 /* FIXME: Given neither BSD nor Linux support anything other than AF_LOCAL
-	 sockets, we deliberately disable AF_INIT socketpairs now and hope for
-	 the best. */
-    case AF_INET:
-      if (type != SOCK_STREAM && type != SOCK_DGRAM)
-        {
-          set_errno (EINVAL);
-          goto done;
-        }
-      dev = type == SOCK_STREAM ? tcp_dev : udp_dev;
-      break;
-#endif
     default:
       set_errno (EAFNOSUPPORT);
       goto done;
@@ -2360,8 +2348,8 @@ socketpair (int af, int type, int protocol, int *sb)
 	  goto done;
 	}
 
-      fh_in = (fhandler_socket *) build_fh_dev (*dev);
-      fh_out = (fhandler_socket *) build_fh_dev (*dev);
+      fh_in = reinterpret_cast<fhandler_socket_local *> (build_fh_dev (*dev));
+      fh_out = reinterpret_cast<fhandler_socket_local *> (build_fh_dev (*dev));
       if (fh_in && fh_out
 	  && fh_in->socketpair (af, type, protocol, flags, fh_out) == 0)
 	{


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]