Cygwin: make socketpair an AF_LOCAL-only method

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2018-02-22 16:25:28 +01:00
parent a3b5795b06
commit 84c5e0fd3d
4 changed files with 5 additions and 32 deletions

View File

@ -574,8 +574,6 @@ class fhandler_socket: public fhandler_base
IMPLEMENT_STATUS_FLAG (bool, no_getpeereid) IMPLEMENT_STATUS_FLAG (bool, no_getpeereid)
virtual int socket (int af, int type, int protocol, int flags) = 0; 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 bind (const struct sockaddr *name, int namelen) = 0;
virtual int listen (int backlog) = 0; virtual int listen (int backlog) = 0;
virtual int accept4 (struct sockaddr *peer, int *len, int flags) = 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 (); ~fhandler_socket_inet ();
int socket (int af, int type, int protocol, int flags); 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 bind (const struct sockaddr *name, int namelen);
int listen (int backlog); int listen (int backlog);
int accept4 (struct sockaddr *peer, int *len, int flags); 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 socket (int af, int type, int protocol, int flags);
int socketpair (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 bind (const struct sockaddr *name, int namelen);
int listen (int backlog); int listen (int backlog);
int accept4 (struct sockaddr *peer, int *len, int flags); int accept4 (struct sockaddr *peer, int *len, int flags);

View File

@ -136,16 +136,6 @@ fhandler_socket_inet::socket (int af, int type, int protocol, int flags)
return ret; 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 int
fhandler_socket_inet::bind (const struct sockaddr *name, int namelen) fhandler_socket_inet::bind (const struct sockaddr *name, int namelen)
{ {

View File

@ -241,7 +241,7 @@ fhandler_socket_local::socket (int af, int type, int protocol, int flags)
int int
fhandler_socket_local::socketpair (int af, int type, int protocol, int flags, 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 insock = INVALID_SOCKET;
SOCKET outsock = 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; struct sockaddr_in sock_in, sock_out;
int len; int len;
fhandler_socket_local *fh_out = (fhandler_socket_local *) _fh_out;
/* create listening socket */ /* create listening socket */
sock = ::socket (AF_INET, type, 0); sock = ::socket (AF_INET, type, 0);
if (sock == INVALID_SOCKET) if (sock == INVALID_SOCKET)

View File

@ -2303,7 +2303,7 @@ socketpair (int af, int type, int protocol, int *sb)
{ {
int res = -1; int res = -1;
const device *dev; const device *dev;
fhandler_socket *fh_in, *fh_out; fhandler_socket_local *fh_in, *fh_out;
int flags = type & _SOCK_FLAG_MASK; int flags = type & _SOCK_FLAG_MASK;
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; dev = type == SOCK_STREAM ? stream_dev : dgram_dev;
break; 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: default:
set_errno (EAFNOSUPPORT); set_errno (EAFNOSUPPORT);
goto done; goto done;
@ -2360,8 +2348,8 @@ socketpair (int af, int type, int protocol, int *sb)
goto done; goto done;
} }
fh_in = (fhandler_socket *) build_fh_dev (*dev); fh_in = reinterpret_cast<fhandler_socket_local *> (build_fh_dev (*dev));
fh_out = (fhandler_socket *) build_fh_dev (*dev); fh_out = reinterpret_cast<fhandler_socket_local *> (build_fh_dev (*dev));
if (fh_in && fh_out if (fh_in && fh_out
&& fh_in->socketpair (af, type, protocol, flags, fh_out) == 0) && fh_in->socketpair (af, type, protocol, flags, fh_out) == 0)
{ {