diff options
author | wtc%netscape.com <devnull@localhost> | 2002-06-11 20:05:32 +0000 |
---|---|---|
committer | wtc%netscape.com <devnull@localhost> | 2002-06-11 20:05:32 +0000 |
commit | 7836c2c89760542f2986cc5c95bd533e25120e74 (patch) | |
tree | ef4ee55aec83b9d4ce5910e19baa1b1cdaa73ca3 | |
parent | d782661a25cf10096336b677748e4a2d7cc500a3 (diff) | |
download | nspr-hg-7836c2c89760542f2986cc5c95bd533e25120e74.tar.gz |
Bug 134099: Worked around two BeOS bugs. 1. connect does not implicitly
bind the socket. 2. accept does not return the peer's address.
Modified files: _beos.h prsocket.c bnet.c
-rw-r--r-- | pr/include/md/_beos.h | 1 | ||||
-rw-r--r-- | pr/src/io/prsocket.c | 11 | ||||
-rw-r--r-- | pr/src/md/beos/bnet.c | 6 |
3 files changed, 15 insertions, 3 deletions
diff --git a/pr/include/md/_beos.h b/pr/include/md/_beos.h index f00bec31..1f69bd66 100644 --- a/pr/include/md/_beos.h +++ b/pr/include/md/_beos.h @@ -91,6 +91,7 @@ #define _PR_HAVE_PEEK_BUFFER #define _PR_PEEK_BUFFER_MAX (16 * 1024) #define _PR_FD_NEED_EMULATE_MSG_PEEK(fd) 1 +#define _PR_CONNECT_DOES_NOT_BIND /* Define threading functions and objects as native BeOS */ struct _MDThread { diff --git a/pr/src/io/prsocket.c b/pr/src/io/prsocket.c index acbc0016..652632fc 100644 --- a/pr/src/io/prsocket.c +++ b/pr/src/io/prsocket.c @@ -1516,6 +1516,17 @@ failed: if (f[0] == NULL) { goto failed; } +#ifdef _PR_CONNECT_DOES_NOT_BIND + /* + * If connect does not implicitly bind the socket (e.g., on + * BeOS), we have to bind the socket so that we can get its + * port with getsockname later. + */ + PR_InitializeNetAddr(PR_IpAddrLoopback, 0, &selfAddr); + if (PR_Bind(f[0], &selfAddr) == PR_FAILURE) { + goto failed; + } +#endif PR_InitializeNetAddr(PR_IpAddrLoopback, port, &selfAddr); /* diff --git a/pr/src/md/beos/bnet.c b/pr/src/md/beos/bnet.c index ba5b666b..13d0b197 100644 --- a/pr/src/md/beos/bnet.c +++ b/pr/src/md/beos/bnet.c @@ -491,6 +491,9 @@ _MD_accept (PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, } if (rv < 0) { _PR_MD_MAP_ACCEPT_ERROR(err); + } else if (addr != NULL) { + /* bug 134099 */ + err = getpeername(rv, (struct sockaddr *) addr, (_PRSockLen_t *)addrlen); } done: #ifdef _PR_HAVE_SOCKADDR_LEN @@ -498,9 +501,6 @@ done: /* Mask off the first byte of struct sockaddr (the length field) */ if (addr) { addr->raw.family = ((struct sockaddr *) addr)->sa_family; -#ifdef IS_LITTLE_ENDIAN - addr->raw.family = ntohs(addr->raw.family); -#endif } } #endif /* _PR_HAVE_SOCKADDR_LEN */ |