From 84c5e0fd3dd263e1e59076e88e65998865d1d9cd Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 22 Feb 2018 16:25:28 +0100 Subject: [PATCH] Cygwin: make socketpair an AF_LOCAL-only method Signed-off-by: Corinna Vinschen --- 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 c50667ca9..4b1d8ddaf 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 a161050e4..06091973f 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 ca1fe5e3c..c5e4bfb67 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 e849b04cc..7c58b91fb 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 (build_fh_dev (*dev)); + fh_out = reinterpret_cast (build_fh_dev (*dev)); if (fh_in && fh_out && fh_in->socketpair (af, type, protocol, flags, fh_out) == 0) {