* net.cc (cygwin_accept): Allow NULL peer and len parameters.

* include/cygwin/socket.h: Define socklen_t as int.
This commit is contained in:
Corinna Vinschen 2001-08-03 12:06:29 +00:00
parent dce6f56397
commit 7eb971a561
3 changed files with 20 additions and 0 deletions

View File

@ -1,3 +1,8 @@
Fri Aug 3 14:02:00 2001 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_accept): Allow NULL peer and len parameters.
* include/cygwin/socket.h: Define socklen_t as int.
Fri Aug 3 13:04:00 2001 Corinna Vinschen <corinna@vinschen.de> Fri Aug 3 13:04:00 2001 Corinna Vinschen <corinna@vinschen.de>
* path.cc (fchdir): Set the fhandler's path to absolute value to * path.cc (fchdir): Set the fhandler's path to absolute value to

View File

@ -40,6 +40,10 @@ struct msghdr
int msg_accrightslen; /* Length of rights list */ int msg_accrightslen; /* Length of rights list */
}; };
#ifndef socklen_t
#define socklen_t int
#endif
/* Socket types. */ /* Socket types. */
#define SOCK_STREAM 1 /* stream (connection) socket */ #define SOCK_STREAM 1 /* stream (connection) socket */
#define SOCK_DGRAM 2 /* datagram (conn.less) socket */ #define SOCK_DGRAM 2 /* datagram (conn.less) socket */

View File

@ -900,6 +900,17 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
fhandler_socket *sock = get (fd); fhandler_socket *sock = get (fd);
if (sock) if (sock)
{ {
/* Allows NULL peer and len parameters. */
struct sockaddr_in peer_dummy;
int len_dummy;
if (!peer)
peer = (struct sockaddr *) &peer_dummy;
if (!len)
{
len_dummy = sizeof (struct sockaddr_in);
len = &len_dummy;
}
/* accept on NT fails if len < sizeof (sockaddr_in) /* accept on NT fails if len < sizeof (sockaddr_in)
* some programs set len to * some programs set len to
* sizeof (name.sun_family) + strlen (name.sun_path) for UNIX domain * sizeof (name.sun_family) + strlen (name.sun_path) for UNIX domain