Cygwin: make socketpair an AF_LOCAL-only method
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
a3b5795b06
commit
84c5e0fd3d
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue