Skip to content

Commit

Permalink
Bug 453372 - Import NSPR_4_7_2_BETA3. r=kaie.
Browse files Browse the repository at this point in the history
  • Loading branch information
wantehchang committed Sep 5, 2008
1 parent 5a3805a commit 7cd34a8
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 16 deletions.
4 changes: 2 additions & 2 deletions nsprpub/configure
Original file line number Diff line number Diff line change
Expand Up @@ -4771,10 +4771,10 @@ EOF
if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
GCC_USE_GNU_LD=1
fi
DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs,-z,ignore'
DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs,-z,ignore,-Bdirect'
else
DSO_CFLAGS=-KPIC
DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs -z ignore'
DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs -z ignore -Bdirect'
fi
if test -n "$GNU_CC"; then
CFLAGS="$CFLAGS -Wall"
Expand Down
4 changes: 2 additions & 2 deletions nsprpub/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -1994,10 +1994,10 @@ mips-sony-newsos*)
if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then
GCC_USE_GNU_LD=1
fi
DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs,-z,ignore'
DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs,-z,ignore,-Bdirect'
else
DSO_CFLAGS=-KPIC
DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs -z ignore'
DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs -z ignore -Bdirect'
fi
if test -n "$GNU_CC"; then
CFLAGS="$CFLAGS -Wall"
Expand Down
1 change: 1 addition & 0 deletions nsprpub/lib/libc/src/strcase.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */

#include "plstr.h"
#include <string.h>

static const unsigned char uc[] =
{
Expand Down
1 change: 1 addition & 0 deletions nsprpub/pr/include/md/_beos.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

#ifdef BONE_VERSION
#define _PR_HAVE_SOCKADDR_LEN
#define HAVE_NETINET_TCP_H
#endif

#define PR_LINKER_ARCH "beos"
Expand Down
1 change: 1 addition & 0 deletions nsprpub/pr/include/md/_os2.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#undef HAVE_THREAD_AFFINITY
#define _PR_HAVE_THREADSAFE_GETHOST
#define _PR_HAVE_ATOMIC_OPS
#define HAVE_NETINET_TCP_H

#define HANDLE unsigned long
#define HINSTANCE HMODULE
Expand Down
4 changes: 4 additions & 0 deletions nsprpub/pr/include/md/_unixos.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
#include <sys/select.h>
#endif

#ifndef SYMBIAN
#define HAVE_NETINET_TCP_H
#endif

#define _PR_HAVE_O_APPEND

#define PR_DIRECTORY_SEPARATOR '/'
Expand Down
2 changes: 1 addition & 1 deletion nsprpub/pr/include/prinit.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ PR_BEGIN_EXTERN_C
** The format of the version string is
** "<major version>.<minor version>[.<patch level>] [<Beta>]"
*/
#define PR_VERSION "4.7.2 Beta 2"
#define PR_VERSION "4.7.2 Beta 3"
#define PR_VMAJOR 4
#define PR_VMINOR 7
#define PR_VPATCH 2
Expand Down
1 change: 0 additions & 1 deletion nsprpub/pr/src/io/prlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ static PRLock *_pr_logLock;

#if defined(XP_PC)
#define strcasecmp stricmp
#define strncasecmp strnicmp
#endif

/*
Expand Down
3 changes: 1 addition & 2 deletions nsprpub/pr/src/io/prmapopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@
#include <netinet/in_systm.h> /* n_short, n_long, n_time */
#endif

#if (defined(XP_UNIX) && !defined(SYMBIAN)) \
|| defined(OS2) || (defined(XP_BEOS) && defined(BONE_VERSION))
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h> /* TCP_NODELAY, TCP_MAXSEG */
#endif

Expand Down
3 changes: 3 additions & 0 deletions nsprpub/pr/src/md/unix/unix_errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ void _MD_unix_map_default_error(int err)
prError = PR_INSUFFICIENT_RESOURCES_ERROR;
break;
#endif
case ENOSYS:
prError = PR_NOT_IMPLEMENTED_ERROR;
break;
case ENOTCONN:
prError = PR_NOT_CONNECTED_ERROR;
break;
Expand Down
117 changes: 109 additions & 8 deletions nsprpub/pr/src/pthreads/ptio.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ static ssize_t (*pt_aix_sendfile_fptr)() = NULL;

#include "primpl.h"

#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h> /* TCP_NODELAY, TCP_MAXSEG */
#endif

#ifdef LINUX
/* TCP_CORK is not defined in <netinet/tcp.h> on Red Hat Linux 6.0 */
#ifndef TCP_CORK
Expand All @@ -209,7 +212,7 @@ static PRBool _pr_ipv6_v6only_on_by_default;
|| defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \
|| defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \
|| defined(BSDI) || defined(VMS) || defined(NTO) || defined(DARWIN) \
|| defined(UNIXWARE) || defined(RISCOS)
|| defined(UNIXWARE) || defined(RISCOS) || defined(SYMBIAN)
#define _PRSelectFdSetArg_t fd_set *
#else
#error "Cannot determine architecture"
Expand Down Expand Up @@ -1656,9 +1659,18 @@ static PRFileDesc* pt_Accept(
PRFileDesc *newfd = NULL;
PRIntn syserrno, osfd = -1;
pt_SockLen addr_len = sizeof(PRNetAddr);
#ifdef SYMBIAN
PRNetAddr dummy_addr;
#endif

if (pt_TestAbort()) return newfd;

#ifdef SYMBIAN
/* On Symbian OS, accept crashes if addr is NULL. */
if (!addr)
addr = &dummy_addr;
#endif

#ifdef _PR_STRICT_ADDR_LEN
if (addr)
{
Expand Down Expand Up @@ -1826,7 +1838,15 @@ static PRInt32 pt_Recv(
if (0 == flags)
osflags = 0;
else if (PR_MSG_PEEK == flags)
{
#ifdef SYMBIAN
/* MSG_PEEK doesn't work as expected. */
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
return bytes;
#else
osflags = MSG_PEEK;
#endif
}
else
{
PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
Expand Down Expand Up @@ -3251,7 +3271,8 @@ static PRIOMethods _pr_socketpollfd_methods = {
|| defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \
|| defined(AIX) || defined(FREEBSD) || defined(NETBSD) \
|| defined(OPENBSD) || defined(BSDI) || defined(VMS) || defined(NTO) \
|| defined(DARWIN) || defined(UNIXWARE) || defined(RISCOS)
|| defined(DARWIN) || defined(UNIXWARE) || defined(RISCOS) \
|| defined(SYMBIAN)
#define _PR_FCNTL_FLAGS O_NONBLOCK
#else
#error "Can't determine architecture"
Expand Down Expand Up @@ -4354,6 +4375,84 @@ PR_IMPLEMENT(PRFileDesc*) PR_OpenTCPSocket(PRIntn af)

PR_IMPLEMENT(PRStatus) PR_NewTCPSocketPair(PRFileDesc *fds[2])
{
#ifdef SYMBIAN
/*
* For the platforms that don't have socketpair.
*
* Copied from prsocket.c, with the parameter f[] renamed fds[] and the
* _PR_CONNECT_DOES_NOT_BIND code removed.
*/
PRFileDesc *listenSock;
PRNetAddr selfAddr, peerAddr;
PRUint16 port;

fds[0] = fds[1] = NULL;
listenSock = PR_NewTCPSocket();
if (listenSock == NULL) {
goto failed;
}
PR_InitializeNetAddr(PR_IpAddrLoopback, 0, &selfAddr); /* BugZilla: 35408 */
if (PR_Bind(listenSock, &selfAddr) == PR_FAILURE) {
goto failed;
}
if (PR_GetSockName(listenSock, &selfAddr) == PR_FAILURE) {
goto failed;
}
port = ntohs(selfAddr.inet.port);
if (PR_Listen(listenSock, 5) == PR_FAILURE) {
goto failed;
}
fds[0] = PR_NewTCPSocket();
if (fds[0] == NULL) {
goto failed;
}
PR_InitializeNetAddr(PR_IpAddrLoopback, port, &selfAddr);

/*
* Only a thread is used to do the connect and accept.
* I am relying on the fact that PR_Connect returns
* successfully as soon as the connect request is put
* into the listen queue (but before PR_Accept is called).
* This is the behavior of the BSD socket code. If
* connect does not return until accept is called, we
* will need to create another thread to call connect.
*/
if (PR_Connect(fds[0], &selfAddr, PR_INTERVAL_NO_TIMEOUT)
== PR_FAILURE) {
goto failed;
}
/*
* A malicious local process may connect to the listening
* socket, so we need to verify that the accepted connection
* is made from our own socket fds[0].
*/
if (PR_GetSockName(fds[0], &selfAddr) == PR_FAILURE) {
goto failed;
}
fds[1] = PR_Accept(listenSock, &peerAddr, PR_INTERVAL_NO_TIMEOUT);
if (fds[1] == NULL) {
goto failed;
}
if (peerAddr.inet.port != selfAddr.inet.port) {
/* the connection we accepted is not from fds[0] */
PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
goto failed;
}
PR_Close(listenSock);
return PR_SUCCESS;

failed:
if (listenSock) {
PR_Close(listenSock);
}
if (fds[0]) {
PR_Close(fds[0]);
}
if (fds[1]) {
PR_Close(fds[1]);
}
return PR_FAILURE;
#else
PRInt32 osfd[2];

if (pt_TestAbort()) return PR_FAILURE;
Expand All @@ -4376,6 +4475,7 @@ PR_IMPLEMENT(PRStatus) PR_NewTCPSocketPair(PRFileDesc *fds[2])
return PR_FAILURE;
}
return PR_SUCCESS;
#endif
} /* PR_NewTCPSocketPair */

PR_IMPLEMENT(PRStatus) PR_CreatePipe(
Expand Down Expand Up @@ -4431,6 +4531,7 @@ PR_IMPLEMENT(PRStatus) PR_SetFDInheritable(
if (fcntl(fd->secret->md.osfd, F_SETFD,
inheritable ? 0 : FD_CLOEXEC) == -1)
{
_PR_MD_MAP_DEFAULT_ERROR(errno);
return PR_FAILURE;
}
fd->secret->inheritable = (_PRTriStateBool) inheritable;
Expand Down Expand Up @@ -4603,21 +4704,23 @@ PR_IMPLEMENT(PRStatus) PR_UnlockFile(PRFileDesc *fd)

PR_IMPLEMENT(PRInt32) PR_GetSysfdTableMax(void)
{
#if defined(XP_UNIX) && !defined(AIX) && !defined(VMS)
#if defined(AIX) || defined(VMS) || defined(SYMBIAN)
return sysconf(_SC_OPEN_MAX);
#else
struct rlimit rlim;

if ( getrlimit(RLIMIT_NOFILE, &rlim) < 0)
return -1;

return rlim.rlim_max;
#elif defined(AIX) || defined(VMS)
return sysconf(_SC_OPEN_MAX);
#endif
}

PR_IMPLEMENT(PRInt32) PR_SetSysfdTableSize(PRIntn table_size)
{
#if defined(XP_UNIX) && !defined(AIX) && !defined(VMS)
#if defined(AIX) || defined(VMS) || defined(SYMBIAN)
return -1;
#else
struct rlimit rlim;
PRInt32 tableMax = PR_GetSysfdTableMax();

Expand All @@ -4634,8 +4737,6 @@ PR_IMPLEMENT(PRInt32) PR_SetSysfdTableSize(PRIntn table_size)
return -1;

return rlim.rlim_cur;
#elif defined(AIX) || defined(VMS)
return -1;
#endif
}

Expand Down

0 comments on commit 7cd34a8

Please sign in to comment.