summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsrinivas%netscape.com <devnull@localhost>1999-10-19 00:40:39 +0000
committersrinivas%netscape.com <devnull@localhost>1999-10-19 00:40:39 +0000
commitcd71910c0a780ea8430fc416c4d6649f6d8674c4 (patch)
treeea6e031c8ad0fa1bac6a4e60b4624bf038e0ed21
parenta01475c029e106b3b0987a3ae050c3ddebc253b2 (diff)
downloadnspr-hg-cd71910c0a780ea8430fc416c4d6649f6d8674c4.tar.gz
Update with post-3.5 fixes on the tip
-rw-r--r--config/Makefile2
-rw-r--r--lib/ds/plvrsion.c5
-rw-r--r--lib/libc/src/plvrsion.c5
-rw-r--r--lib/prstreams/plvrsion.c5
-rw-r--r--pr/include/md/_pcos.h2
-rw-r--r--pr/include/md/_unixos.h5
-rw-r--r--pr/include/prio.h5
-rw-r--r--pr/include/private/pprio.h17
-rw-r--r--pr/include/private/primpl.h22
-rw-r--r--pr/src/io/prfdcach.c29
-rw-r--r--pr/src/io/prfile.c60
-rw-r--r--pr/src/io/prlayer.c15
-rw-r--r--pr/src/io/prmapopt.c6
-rw-r--r--pr/src/md/mac/macsocket.h1
-rw-r--r--pr/src/md/unix/Makefile7
-rw-r--r--pr/src/md/unix/objs.mk5
-rw-r--r--pr/src/md/unix/unix.c21
-rw-r--r--pr/src/md/unix/uxpoll.c5
-rw-r--r--pr/src/md/windows/ntmisc.c69
-rw-r--r--pr/src/md/windows/w95io.c58
-rw-r--r--pr/src/misc/prsystem.c18
-rw-r--r--pr/src/prvrsion.c5
-rw-r--r--pr/src/pthreads/ptio.c47
-rw-r--r--pr/src/pthreads/ptthread.c27
-rw-r--r--pr/src/threads/prrwlock.c1
-rw-r--r--pr/tests/Makefile4
-rw-r--r--pr/tests/cltsrv.c1
-rw-r--r--pr/tests/pipeping.c10
-rw-r--r--pr/tests/poll_nm.c1
-rw-r--r--pr/tests/poll_to.c1
-rw-r--r--pr/tests/provider.c1
-rwxr-xr-xpr/tests/runtests.ksh6
-rw-r--r--pr/tests/sigpipe.c1
-rw-r--r--pr/tests/sockopt.c11
-rw-r--r--pr/tests/sockping.c6
-rw-r--r--pr/tests/stack.c31
36 files changed, 396 insertions, 119 deletions
diff --git a/config/Makefile b/config/Makefile
index 36ac7809..4625ce73 100644
--- a/config/Makefile
+++ b/config/Makefile
@@ -60,7 +60,7 @@ endif
ifeq ($(OS_ARCH), HP-UX)
ifeq ($(USE_64),1)
- XLDOPTS += +DD64
+ XLDOPTS += +DA2.0W
endif
endif
diff --git a/lib/ds/plvrsion.c b/lib/ds/plvrsion.c
index bc5ee7dd..692db47c 100644
--- a/lib/ds/plvrsion.c
+++ b/lib/ds/plvrsion.c
@@ -69,8 +69,11 @@ static PRVersionDescription prVersionDescription_libplds3 =
/*
* Version information for the 'ident' and 'what commands
+ *
+ * NOTE: the first component of the concatenated rcsid string
+ * must not end in a '$' to prevent rcs keyword substitution.
*/
-static char rcsid[] = "$Version: NSPR " PR_VERSION _DEBUG_STRING
+static char rcsid[] = "$Header: NSPR " PR_VERSION _DEBUG_STRING
" " _BUILD_STRING " $";
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
" " _BUILD_STRING;
diff --git a/lib/libc/src/plvrsion.c b/lib/libc/src/plvrsion.c
index 70dff093..48afcf78 100644
--- a/lib/libc/src/plvrsion.c
+++ b/lib/libc/src/plvrsion.c
@@ -69,8 +69,11 @@ static PRVersionDescription prVersionDescription_libplc3 =
/*
* Version information for the 'ident' and 'what commands
+ *
+ * NOTE: the first component of the concatenated rcsid string
+ * must not end in a '$' to prevent rcs keyword substitution.
*/
-static char rcsid[] = "$Version: NSPR " PR_VERSION _DEBUG_STRING
+static char rcsid[] = "$Header: NSPR " PR_VERSION _DEBUG_STRING
" " _BUILD_STRING " $";
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
" " _BUILD_STRING;
diff --git a/lib/prstreams/plvrsion.c b/lib/prstreams/plvrsion.c
index 9a187c97..c765ecac 100644
--- a/lib/prstreams/plvrsion.c
+++ b/lib/prstreams/plvrsion.c
@@ -69,8 +69,11 @@ static PRVersionDescription prVersionDescription_libprstrms3 =
/*
* Version information for the 'ident' and 'what commands
+ *
+ * NOTE: the first component of the concatenated rcsid string
+ * must not end in a '$' to prevent rcs keyword substitution.
*/
-static char rcsid[] = "$Version: NSPR " PR_VERSION _DEBUG_STRING
+static char rcsid[] = "$Header: NSPR " PR_VERSION _DEBUG_STRING
" " _BUILD_STRING " $";
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
" " _BUILD_STRING;
diff --git a/pr/include/md/_pcos.h b/pr/include/md/_pcos.h
index 3ffe5dad..946f6f65 100644
--- a/pr/include/md/_pcos.h
+++ b/pr/include/md/_pcos.h
@@ -63,6 +63,8 @@ extern PRStatus _MD_OS2GetHostName(char *name, PRUint32 namelen);
#else
extern PRStatus _MD_WindowsGetHostName(char *name, PRUint32 namelen);
#define _MD_GETHOSTNAME _MD_WindowsGetHostName
+extern PRStatus _MD_WindowsGetSysInfo(PRSysInfo cmd, char *name, PRUint32 namelen);
+#define _MD_GETSYSINFO _MD_WindowsGetSysInfo
#endif
#endif /* prpcos_h___ */
diff --git a/pr/include/md/_unixos.h b/pr/include/md/_unixos.h
index 53684bbe..9dd1f1fe 100644
--- a/pr/include/md/_unixos.h
+++ b/pr/include/md/_unixos.h
@@ -393,6 +393,8 @@ extern PRInt32 _MD_socketavailable(PRFileDesc *fd);
extern PRInt64 _MD_socketavailable64(PRFileDesc *fd);
#define _MD_SOCKETAVAILABLE64 _MD_socketavailable64
+#define _MD_PIPEAVAILABLE _MD_socketavailable
+
extern PRInt32 _MD_pr_poll(PRPollDesc *pds, PRIntn npds,
PRIntervalTime timeout);
#define _MD_PR_POLL _MD_pr_poll
@@ -435,6 +437,9 @@ extern PRStatus _MD_set_fd_inheritable(PRFileDesc *fd, PRBool inheritable);
extern PRStatus _MD_gethostname(char *name, PRUint32 namelen);
#define _MD_GETHOSTNAME _MD_gethostname
+extern PRStatus _MD_getsysinfo(PRSysInfo cmd, char *name, PRUint32 namelen);
+#define _MD_GETSYSINFO _MD_getsysinfo
+
extern int _MD_unix_get_nonblocking_connect_error(int osfd);
#define HAVE_SOCKET_REUSEADDR
diff --git a/pr/include/prio.h b/pr/include/prio.h
index 5ced4fb4..c0c6983f 100644
--- a/pr/include/prio.h
+++ b/pr/include/prio.h
@@ -219,6 +219,7 @@ typedef enum PRSockOption
PR_SockOpt_NoDelay, /* don't delay send to coalesce packets */
PR_SockOpt_MaxSegment, /* maximum segment size */
+ PR_SockOpt_Broadcast, /* enable broadcast */
PR_SockOpt_Last
} PRSockOption;
@@ -245,6 +246,7 @@ typedef struct PRSocketOptionData
PRBool keep_alive; /* Keep connections alive */
PRBool mcast_loopback; /* IP multicast loopback */
PRBool no_delay; /* Don't delay send to coalesce packets */
+ PRBool broadcast; /* Enable broadcast */
PRSize max_segment; /* Maximum segment size */
PRSize recv_buffer_size; /* Receive buffer size */
PRSize send_buffer_size; /* Send buffer size */
@@ -278,7 +280,8 @@ typedef enum PRDescType
PR_DESC_FILE = 1,
PR_DESC_SOCKET_TCP = 2,
PR_DESC_SOCKET_UDP = 3,
- PR_DESC_LAYERED = 4
+ PR_DESC_LAYERED = 4,
+ PR_DESC_PIPE = 5
} PRDescType;
typedef enum PRSeekWhence {
diff --git a/pr/include/private/pprio.h b/pr/include/private/pprio.h
index 02dbcb9a..9ae71cc8 100644
--- a/pr/include/private/pprio.h
+++ b/pr/include/private/pprio.h
@@ -30,22 +30,6 @@
PR_BEGIN_EXTERN_C
-/*
-** File descriptors of the NSPR layer can be in one of the
-** following states (stored in the 'state' field of struct
-** PRFilePrivate):
-** - _PR_FILEDESC_OPEN: The OS fd is open.
-** - _PR_FILEDESC_CLOSED: The OS fd is closed. The PRFileDesc
-** is still open but is unusable. The only operation allowed
-** on the PRFileDesc is PR_Close().
-** - _PR_FILEDESC_FREED: The OS fd is closed and the PRFileDesc
-** structure is freed.
-*/
-
-#define _PR_FILEDESC_OPEN 0xaaaaaaaa /* 1010101... */
-#define _PR_FILEDESC_CLOSED 0x55555555 /* 0101010... */
-#define _PR_FILEDESC_FREED 0x11111111
-
/************************************************************************/
/************************************************************************/
@@ -53,6 +37,7 @@ PR_BEGIN_EXTERN_C
PR_EXTERN(const PRIOMethods*) PR_GetFileMethods(void);
PR_EXTERN(const PRIOMethods*) PR_GetTCPMethods(void);
PR_EXTERN(const PRIOMethods*) PR_GetUDPMethods(void);
+PR_EXTERN(const PRIOMethods*) PR_GetPipeMethods(void);
/*
** Convert a NSPR Socket Handle to a Native Socket handle.
diff --git a/pr/include/private/primpl.h b/pr/include/private/primpl.h
index 1d5a31f0..04e08b86 100644
--- a/pr/include/private/primpl.h
+++ b/pr/include/private/primpl.h
@@ -1165,6 +1165,9 @@ extern PRInt32 _PR_MD_SOCKET(int af, int type, int flags);
extern PRInt32 _PR_MD_SOCKETAVAILABLE(PRFileDesc *fd);
#define _PR_MD_SOCKETAVAILABLE _MD_SOCKETAVAILABLE
+extern PRInt32 _PR_MD_PIPEAVAILABLE(PRFileDesc *fd);
+#define _PR_MD_PIPEAVAILABLE _MD_PIPEAVAILABLE
+
extern PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds,
PRIntervalTime timeout);
#define _PR_MD_PR_POLL _MD_PR_POLL
@@ -1503,6 +1506,22 @@ struct PRFileMap {
/************************************************************************/
+/*
+** File descriptors of the NSPR layer can be in one of the
+** following states (stored in the 'state' field of struct
+** PRFilePrivate):
+** - _PR_FILEDESC_OPEN: The OS fd is open.
+** - _PR_FILEDESC_CLOSED: The OS fd is closed. The PRFileDesc
+** is still open but is unusable. The only operation allowed
+** on the PRFileDesc is PR_Close().
+** - _PR_FILEDESC_FREED: The OS fd is closed and the PRFileDesc
+** structure is freed.
+*/
+
+#define _PR_FILEDESC_OPEN 0xaaaaaaaa /* 1010101... */
+#define _PR_FILEDESC_CLOSED 0x55555555 /* 0101010... */
+#define _PR_FILEDESC_FREED 0x11111111
+
struct PRFilePrivate {
PRInt32 state;
PRBool nonblocking;
@@ -1876,6 +1895,9 @@ PR_EXTERN(PRInt32) _PR_MD_GET_SOCKET_ERROR(void);
extern PRStatus _PR_MD_GETHOSTNAME(char *name, PRUint32 namelen);
#define _PR_MD_GETHOSTNAME _MD_GETHOSTNAME
+extern PRStatus _PR_MD_GETSYSINFO(PRSysInfo cmd, char *name, PRUint32 namelen);
+#define _PR_MD_GETSYSINFO _MD_GETSYSINFO
+
#ifdef XP_BEOS
extern PRLock *_connectLock;
diff --git a/pr/src/io/prfdcach.c b/pr/src/io/prfdcach.c
index 64f164b8..6ad2e84c 100644
--- a/pr/src/io/prfdcach.c
+++ b/pr/src/io/prfdcach.c
@@ -17,7 +17,6 @@
*/
#include "primpl.h"
-#include "pratom.h"
#include <string.h>
@@ -182,6 +181,8 @@ PR_IMPLEMENT(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high)
** turn the caches off, or turn them on. It is not dependent
** on the compilation setting of DEBUG.
*/
+ if (!_pr_initialized) _PR_ImplicitInitialization();
+
if (low > high) low = high; /* sanity check the params */
PR_Lock(_pr_fd_cache.ml);
@@ -201,8 +202,7 @@ PR_IMPLEMENT(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high)
{
PRFileDesc *fd = _pr_fd_cache.head;
_pr_fd_cache.head = fd->higher;
- fd->identity = PR_NSPR_IO_LAYER;
- _PR_Putfd(fd);
+ PR_StackPush(_pr_fd_cache.stack, (PRStackElem*)(&fd->higher));
}
_pr_fd_cache.limit_low = 0;
_pr_fd_cache.tail = NULL;
@@ -211,18 +211,20 @@ PR_IMPLEMENT(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high)
}
else /* starting up or just adjusting parameters */
{
- PRBool was_using_cache = (0 != _pr_fd_cache.limit_high);
+ PRBool was_using_stack = (0 == _pr_fd_cache.limit_high);
_pr_fd_cache.limit_low = low;
_pr_fd_cache.limit_high = high;
- if (was_using_cache) /* was using stack - feed into cache */
+ if (was_using_stack) /* was using stack - feed into cache */
{
PRStackElem *pop;
while (NULL != (pop = PR_StackPop(_pr_fd_cache.stack)))
{
PRFileDesc *fd = (PRFileDesc*)
((PRPtrdiff)pop - (PRPtrdiff)stack2fd);
- fd->identity = PR_NSPR_IO_LAYER;
- _PR_Putfd(fd);
+ if (NULL == _pr_fd_cache.tail) _pr_fd_cache.tail = fd;
+ fd->higher = _pr_fd_cache.head;
+ _pr_fd_cache.head = fd;
+ _pr_fd_cache.count += 1;
}
}
}
@@ -241,20 +243,21 @@ void _PR_InitFdCache()
const char *low = PR_GetEnv("NSPR_FD_CACHE_SIZE_LOW");
const char *high = PR_GetEnv("NSPR_FD_CACHE_SIZE_HIGH");
- _pr_fd_cache.limit_low = _pr_fd_cache.limit_high = 0;
- if (NULL != low) _pr_fd_cache.limit_low = atoi(low);
- if (NULL != high) _pr_fd_cache.limit_high = atoi(high);
-
/*
** _low is allowed to be zero, _high is not.
** If _high is zero, we're not doing the caching.
*/
+ _pr_fd_cache.limit_low = 0;
#if defined(DEBUG)
- if (0 == _pr_fd_cache.limit_high)
- _pr_fd_cache.limit_high = FD_SETSIZE;
+ _pr_fd_cache.limit_high = FD_SETSIZE;
+#else
+ _pr_fd_cache.limit_high = 0;
#endif /* defined(DEBUG) */
+ if (NULL != low) _pr_fd_cache.limit_low = atoi(low);
+ if (NULL != high) _pr_fd_cache.limit_high = atoi(high);
+
if (_pr_fd_cache.limit_high < _pr_fd_cache.limit_low)
_pr_fd_cache.limit_high = _pr_fd_cache.limit_low;
diff --git a/pr/src/io/prfile.c b/pr/src/io/prfile.c
index 993bfe45..aae96f12 100644
--- a/pr/src/io/prfile.c
+++ b/pr/src/io/prfile.c
@@ -155,6 +155,20 @@ static PRInt64 PR_CALLBACK FileAvailable64(PRFileDesc *fd)
return result;
}
+static PRInt32 PR_CALLBACK PipeAvailable(PRFileDesc *fd)
+{
+ PRInt32 rv;
+ rv = _PR_MD_PIPEAVAILABLE(fd);
+ return rv;
+}
+
+static PRInt64 PR_CALLBACK PipeAvailable64(PRFileDesc *fd)
+{
+ PRInt64 rv;
+ LL_I2L(rv, _PR_MD_PIPEAVAILABLE(fd));
+ return rv;
+}
+
static PRStatus PR_CALLBACK FileInfo(PRFileDesc *fd, PRFileInfo *info)
{
PRInt32 rv;
@@ -256,6 +270,44 @@ PR_IMPLEMENT(const PRIOMethods*) PR_GetFileMethods(void)
return &_pr_fileMethods;
}
+static PRIOMethods _pr_pipeMethods = {
+ PR_DESC_PIPE,
+ FileClose,
+ FileRead,
+ FileWrite,
+#ifdef WIN32
+ FileAvailable,
+ FileAvailable64,
+#else
+ PipeAvailable,
+ PipeAvailable64,
+#endif
+ FileSync,
+ (PRSeekFN)_PR_InvalidInt,
+ (PRSeek64FN)_PR_InvalidInt64,
+ (PRFileInfoFN)_PR_InvalidStatus,
+ (PRFileInfo64FN)_PR_InvalidStatus,
+ (PRWritevFN)_PR_InvalidInt,
+ (PRConnectFN)_PR_InvalidStatus,
+ (PRAcceptFN)_PR_InvalidDesc,
+ (PRBindFN)_PR_InvalidStatus,
+ (PRListenFN)_PR_InvalidStatus,
+ (PRShutdownFN)_PR_InvalidStatus,
+ (PRRecvFN)_PR_InvalidInt,
+ (PRSendFN)_PR_InvalidInt,
+ (PRRecvfromFN)_PR_InvalidInt,
+ (PRSendtoFN)_PR_InvalidInt,
+ FilePoll,
+ (PRAcceptreadFN)_PR_InvalidInt,
+ (PRTransmitfileFN)_PR_InvalidInt,
+ (PRGetsocknameFN)_PR_InvalidStatus,
+ (PRGetpeernameFN)_PR_InvalidStatus,
+ (PRGetsockoptFN)_PR_InvalidStatus,
+ (PRSetsockoptFN)_PR_InvalidStatus,
+ (PRGetsocketoptionFN)_PR_InvalidStatus,
+ (PRSetsocketoptionFN)_PR_InvalidStatus
+};
+
PR_IMPLEMENT(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode)
{
PRInt32 osfd;
@@ -553,13 +605,13 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe(
PR_SetError(PR_UNKNOWN_ERROR, GetLastError());
return PR_FAILURE;
}
- *readPipe = PR_AllocFileDesc((PRInt32)readEnd, &_pr_fileMethods);
+ *readPipe = PR_AllocFileDesc((PRInt32)readEnd, &_pr_pipeMethods);
if (NULL == *readPipe) {
CloseHandle(readEnd);
CloseHandle(writeEnd);
return PR_FAILURE;
}
- *writePipe = PR_AllocFileDesc((PRInt32)writeEnd, &_pr_fileMethods);
+ *writePipe = PR_AllocFileDesc((PRInt32)writeEnd, &_pr_pipeMethods);
if (NULL == *writePipe) {
PR_Close(*readPipe);
CloseHandle(writeEnd);
@@ -582,13 +634,13 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe(
PR_SetError(PR_UNKNOWN_ERROR, errno);
return PR_FAILURE;
}
- *readPipe = PR_AllocFileDesc(pipefd[0], &_pr_fileMethods);
+ *readPipe = PR_AllocFileDesc(pipefd[0], &_pr_pipeMethods);
if (NULL == *readPipe) {
close(pipefd[0]);
close(pipefd[1]);
return PR_FAILURE;
}
- *writePipe = PR_AllocFileDesc(pipefd[1], &_pr_fileMethods);
+ *writePipe = PR_AllocFileDesc(pipefd[1], &_pr_pipeMethods);
if (NULL == *writePipe) {
PR_Close(*readPipe);
close(pipefd[1]);
diff --git a/pr/src/io/prlayer.c b/pr/src/io/prlayer.c
index 43060295..d1861f93 100644
--- a/pr/src/io/prlayer.c
+++ b/pr/src/io/prlayer.c
@@ -43,17 +43,20 @@ void PR_CALLBACK pl_FDDestructor(PRFileDesc *fd)
*/
static PRStatus PR_CALLBACK pl_TopClose (PRFileDesc *fd)
{
- PRStatus status;
+ PRFileDesc *top;
PR_ASSERT(fd != NULL);
PR_ASSERT(fd->lower != NULL);
PR_ASSERT(fd->secret == NULL);
PR_ASSERT(fd->methods->file_type == PR_DESC_LAYERED);
- status = (fd->lower->methods->close)(fd->lower);
- fd->lower = fd->higher = NULL;
-
- fd->dtor(fd);
- return status;
+ if (fd->higher != NULL)
+ {
+ PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);
+ return PR_FAILURE;
+ }
+ top = PR_PopIOLayer(fd, PR_TOP_IO_LAYER);
+ top->dtor(top);
+ return (fd->methods->close)(fd);
}
static PRInt32 PR_CALLBACK pl_DefRead (PRFileDesc *fd, void *buf, PRInt32 amount)
diff --git a/pr/src/io/prmapopt.c b/pr/src/io/prmapopt.c
index 1d618187..e99ce600 100644
--- a/pr/src/io/prmapopt.c
+++ b/pr/src/io/prmapopt.c
@@ -92,6 +92,7 @@ PRStatus PR_CALLBACK _PR_SocketGetSocketOption(PRFileDesc *fd, PRSocketOptionDat
case PR_SockOpt_Reuseaddr:
case PR_SockOpt_Keepalive:
case PR_SockOpt_NoDelay:
+ case PR_SockOpt_Broadcast:
{
#ifdef WIN32 /* Winsock */
BOOL value;
@@ -242,6 +243,7 @@ PRStatus PR_CALLBACK _PR_SocketSetSocketOption(PRFileDesc *fd, const PRSocketOpt
case PR_SockOpt_Reuseaddr:
case PR_SockOpt_Keepalive:
case PR_SockOpt_NoDelay:
+ case PR_SockOpt_Broadcast:
{
#ifdef WIN32 /* Winsock */
BOOL value;
@@ -454,14 +456,14 @@ PRStatus _PR_MapOptionName(
0, SO_LINGER, SO_REUSEADDR, SO_KEEPALIVE, SO_RCVBUF, SO_SNDBUF,
IP_TTL, IP_TOS, IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP,
IP_MULTICAST_IF, IP_MULTICAST_TTL, IP_MULTICAST_LOOP,
- TCP_NODELAY, TCP_MAXSEG
+ TCP_NODELAY, TCP_MAXSEG, SO_BROADCAST
};
static PRInt32 socketLevels[PR_SockOpt_Last] =
{
0, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET, SOL_SOCKET,
IPPROTO_IP, IPPROTO_IP, IPPROTO_IP, IPPROTO_IP,
IPPROTO_IP, IPPROTO_IP, IPPROTO_IP,
- IPPROTO_TCP, IPPROTO_TCP
+ IPPROTO_TCP, IPPROTO_TCP, SOL_SOCKET
};
if ((optname < PR_SockOpt_Linger)
diff --git a/pr/src/md/mac/macsocket.h b/pr/src/md/mac/macsocket.h
index 97701a61..9c4612d2 100644
--- a/pr/src/md/mac/macsocket.h
+++ b/pr/src/md/mac/macsocket.h
@@ -80,6 +80,7 @@ struct hostent {
#define INADDR_ANY kOTAnyInetAddress
#define SOL_SOCKET XTI_GENERIC // Any type of socket
#define SO_REUSEADDR IP_REUSEADDR
+#define SO_BROADCAST IP_BROADCAST
#define MSG_PEEK 0x2 // Just look at a message waiting, donŐt actually read it.
typedef unsigned long u_long;
diff --git a/pr/src/md/unix/Makefile b/pr/src/md/unix/Makefile
index 9a36af8f..cfbed71a 100644
--- a/pr/src/md/unix/Makefile
+++ b/pr/src/md/unix/Makefile
@@ -30,11 +30,14 @@ CSRCS = \
unix.c \
unix_errors.c \
uxproces.c \
- uxwrap.c \
- uxpoll.c \
uxshm.c \
+ uxwrap.c \
$(NULL)
+ifneq ($(USE_PTHREADS),1)
+CSRCS += uxpoll.c
+endif
+
PTH_USER_CSRCS = \
pthreads_user.c \
$(NULL)
diff --git a/pr/src/md/unix/objs.mk b/pr/src/md/unix/objs.mk
index 4fc32f55..f4d1326e 100644
--- a/pr/src/md/unix/objs.mk
+++ b/pr/src/md/unix/objs.mk
@@ -24,9 +24,12 @@ CSRCS = \
uxproces.c \
uxshm.c \
uxwrap.c \
- uxpoll.c \
$(NULL)
+ifneq ($(USE_PTHREADS),1)
+CSRCS += uxpoll.c
+endif
+
PTH_USER_CSRCS = \
pthreads_user.c \
$(NULL)
diff --git a/pr/src/md/unix/unix.c b/pr/src/md/unix/unix.c
index fd871585..aa3cf45a 100644
--- a/pr/src/md/unix/unix.c
+++ b/pr/src/md/unix/unix.c
@@ -27,6 +27,8 @@
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
+#include <unistd.h>
+#include <sys/utsname.h>
#ifdef _PR_POLL_AVAILABLE
#include <poll.h>
@@ -3691,6 +3693,25 @@ PR_IMPLEMENT(PRStatus) _MD_gethostname(char *name, PRUint32 namelen)
return PR_FAILURE;
}
+PR_IMPLEMENT(PRStatus) _MD_getsysinfo(PRSysInfo cmd, char *name, PRUint32 namelen)
+{
+ struct utsname info;
+
+ PR_ASSERT((cmd == PR_SI_SYSNAME) || (cmd == PR_SI_RELEASE));
+
+ if (uname(&info) == -1) {
+ _PR_MD_MAP_DEFAULT_ERROR(errno);
+ return PR_FAILURE;
+ }
+ if (PR_SI_SYSNAME == cmd)
+ (void)PR_snprintf(name, namelen, info.sysname);
+ else if (PR_SI_RELEASE == cmd)
+ (void)PR_snprintf(name, namelen, info.release);
+ else
+ return PR_FAILURE;
+ return PR_SUCCESS;
+}
+
/*
*******************************************************************
*
diff --git a/pr/src/md/unix/uxpoll.c b/pr/src/md/unix/uxpoll.c
index 373d9e27..7599ea67 100644
--- a/pr/src/md/unix/uxpoll.c
+++ b/pr/src/md/unix/uxpoll.c
@@ -18,8 +18,7 @@
#if defined(_PR_PTHREADS)
-/* Some compilers don't like an empty source file. */
-static int dummy = 0;
+#error "This file should not be compiled"
#else /* defined(_PR_PTHREADS) */
@@ -681,5 +680,5 @@ PRInt32 _MD_pr_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
#endif /* defined(_PR_PTHREADS) */
-/* pruxpoll.c */
+/* uxpoll.c */
diff --git a/pr/src/md/windows/ntmisc.c b/pr/src/md/windows/ntmisc.c
index 9afaac2e..6ef02f6d 100644
--- a/pr/src/md/windows/ntmisc.c
+++ b/pr/src/md/windows/ntmisc.c
@@ -551,6 +551,75 @@ PRStatus _MD_WindowsGetHostName(char *name, PRUint32 namelen)
return PR_FAILURE;
}
+PRStatus _MD_WindowsGetSysInfo(PRSysInfo cmd, char *name, PRUint32 namelen)
+{
+ OSVERSIONINFO osvi;
+
+ PR_ASSERT((cmd == PR_SI_SYSNAME) || (cmd == PR_SI_RELEASE));
+
+ ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+ if (! GetVersionEx (&osvi) ) {
+ _PR_MD_MAP_DEFAULT_ERROR(GetLastError());
+ return PR_FAILURE;
+ }
+
+ switch (osvi.dwPlatformId) {
+ case VER_PLATFORM_WIN32_NT:
+ if (PR_SI_SYSNAME == cmd)
+ (void)PR_snprintf(name, namelen, "Windows_NT");
+ else if (PR_SI_RELEASE == cmd)
+ (void)PR_snprintf(name, namelen, "%d.%d",osvi.dwMajorVersion,
+ osvi.dwMinorVersion);
+ break;
+ case VER_PLATFORM_WIN32_WINDOWS:
+ if (PR_SI_SYSNAME == cmd) {
+ if ((osvi.dwMajorVersion > 4) ||
+ ((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0)))
+ (void)PR_snprintf(name, namelen, "Windows_98");
+ else
+ (void)PR_snprintf(name, namelen, "Windows_95");
+ } else if (PR_SI_RELEASE == cmd) {
+ (void)PR_snprintf(name, namelen, "%d.%d",osvi.dwMajorVersion,
+ osvi.dwMinorVersion);
+ }
+ break;
+ default:
+ if (PR_SI_SYSNAME == cmd)
+ (void)PR_snprintf(name, namelen, "Windows_Unknown");
+ else if (PR_SI_RELEASE == cmd)
+ (void)PR_snprintf(name, namelen, "%d.%d",0,0);
+ break;
+ }
+ return PR_SUCCESS;
+}
+
+PRStatus _MD_WindowsGetReleaseName(char *name, PRUint32 namelen)
+{
+ OSVERSIONINFO osvi;
+
+ ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+ if (! GetVersionEx (&osvi) ) {
+ _PR_MD_MAP_DEFAULT_ERROR(GetLastError());
+ return PR_FAILURE;
+ }
+
+ switch (osvi.dwPlatformId) {
+ case VER_PLATFORM_WIN32_NT:
+ case VER_PLATFORM_WIN32_WINDOWS:
+ (void)PR_snprintf(name, namelen, "%d.%d",osvi.dwMajorVersion,
+ osvi.dwMinorVersion);
+ break;
+ default:
+ (void)PR_snprintf(name, namelen, "%d.%d",0,0);
+ break;
+ }
+ return PR_SUCCESS;
+}
+
/*
**********************************************************************
*
diff --git a/pr/src/md/windows/w95io.c b/pr/src/md/windows/w95io.c
index 89333276..af8c63e3 100644
--- a/pr/src/md/windows/w95io.c
+++ b/pr/src/md/windows/w95io.c
@@ -874,51 +874,27 @@ _PR_MD_RMDIR(const char *name)
PRStatus
_PR_MD_LOCKFILE(PRInt32 f)
{
- PRInt32 rv;
+ PRStatus rc = PR_SUCCESS;
+ DWORD rv;
- /*
- * loop trying to LockFile(),
- * pause for a few miliseconds when can't get the lock
- * and try again
- */
- for( rv = FALSE; rv == FALSE; /* do nothing */ )
- {
-
- rv = LockFile( (HANDLE) f,
- 0l, 0l,
- 0x7fffffff, 0xffffffff );
- if ( rv == FALSE )
- {
- DWORD rc = GetLastError();
- Sleep( 50 ); // Sleep() a few milisecs and try again.
- }
- } /* end for() */
- return PR_SUCCESS;
+ rv = LockFile( (HANDLE)f,
+ 0l, 0l,
+ 0x0l, 0xffffffffl );
+ if ( rv == 0 ) {
+ DWORD rc = GetLastError();
+ PR_LOG( _pr_io_lm, PR_LOG_ERROR,
+ ("_PR_MD_LOCKFILE() failed. Error: %d", rc ));
+ rc = PR_FAILURE;
+ }
+
+ return rc;
} /* end _PR_MD_LOCKFILE() */
PRStatus
_PR_MD_TLOCKFILE(PRInt32 f)
{
- PRInt32 rv;
-
- /*
- * loop trying to LockFile(),
- * pause for a few miliseconds when can't get the lock
- * and try again
- */
- for( rv = FALSE; rv == FALSE; /* do nothing */ )
- {
-
- rv = LockFile( (HANDLE) f,
- 0l, 0l,
- 0x7fffffff, 0xffffffff );
- if ( rv == FALSE )
- {
- DWORD rc = GetLastError();
- Sleep( 50 ); // Sleep() a few milisecs and try again.
- }
- } /* end for() */
- return PR_SUCCESS;
+ PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
+ return PR_FAILURE;
} /* end _PR_MD_TLOCKFILE() */
@@ -929,7 +905,7 @@ _PR_MD_UNLOCKFILE(PRInt32 f)
rv = UnlockFile( (HANDLE) f,
0l, 0l,
- 0x7fffffff, 0xffffffff );
+ 0x0l, 0xffffffffl );
if ( rv )
{
@@ -937,7 +913,7 @@ _PR_MD_UNLOCKFILE(PRInt32 f)
}
else
{
- int err = GetLastError();
+ _PR_MD_MAP_DEFAULT_ERROR(GetLastError());
return PR_FAILURE;
}
} /* end _PR_MD_UNLOCKFILE() */
diff --git a/pr/src/misc/prsystem.c b/pr/src/misc/prsystem.c
index c7add980..574791d3 100644
--- a/pr/src/misc/prsystem.c
+++ b/pr/src/misc/prsystem.c
@@ -68,17 +68,19 @@ PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 bufle
case PR_SI_SYSNAME:
/* Return the operating system name */
+#if defined(XP_UNIX) || defined(WIN32)
+ if (PR_FAILURE == _PR_MD_GETSYSINFO(cmd, buf, (PRUintn)buflen))
+ return PR_FAILURE;
+#else
(void)PR_snprintf(buf, buflen, _PR_SI_SYSNAME);
+#endif
break;
case PR_SI_RELEASE:
/* Return the version of the operating system */
-#if defined(XP_UNIX)
- {
- struct utsname info;
- uname(&info);
- (void)PR_snprintf(buf, buflen, info.release);
- }
+#if defined(XP_UNIX) || defined(WIN32)
+ if (PR_FAILURE == _PR_MD_GETSYSINFO(cmd, buf, (PRUintn)buflen))
+ return PR_FAILURE;
#endif
#if defined(XP_OS2)
{
@@ -101,6 +103,10 @@ PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 bufle
/* Return the architecture of the machine (ie. x86, mips, alpha, ...)*/
(void)PR_snprintf(buf, buflen, _PR_SI_ARCHITECTURE);
break;
+ default:
+ PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
+ return PR_FAILURE;
+ break;
}
return PR_SUCCESS;
}
diff --git a/pr/src/prvrsion.c b/pr/src/prvrsion.c
index 6c5e59a3..b5146483 100644
--- a/pr/src/prvrsion.c
+++ b/pr/src/prvrsion.c
@@ -69,8 +69,11 @@ static PRVersionDescription prVersionDescription_libnspr3 =
/*
* Version information for the 'ident' and 'what commands
+ *
+ * NOTE: the first component of the concatenated rcsid string
+ * must not end in a '$' to prevent rcs keyword substitution.
*/
-static char rcsid[] = "$Version: NSPR " PR_VERSION _DEBUG_STRING
+static char rcsid[] = "$Header: NSPR " PR_VERSION _DEBUG_STRING
" " _BUILD_STRING " $";
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
" " _BUILD_STRING;
diff --git a/pr/src/pthreads/ptio.c b/pr/src/pthreads/ptio.c
index 3b2fa4c8..96d5520a 100644
--- a/pr/src/pthreads/ptio.c
+++ b/pr/src/pthreads/ptio.c
@@ -2639,6 +2639,7 @@ static PRStatus pt_GetSocketOption(PRFileDesc *fd, PRSocketOptionData *data)
case PR_SockOpt_Reuseaddr:
case PR_SockOpt_Keepalive:
case PR_SockOpt_NoDelay:
+ case PR_SockOpt_Broadcast:
{
PRIntn value;
length = sizeof(PRIntn);
@@ -2757,6 +2758,7 @@ static PRStatus pt_SetSocketOption(PRFileDesc *fd, const PRSocketOptionData *dat
case PR_SockOpt_Reuseaddr:
case PR_SockOpt_Keepalive:
case PR_SockOpt_NoDelay:
+ case PR_SockOpt_Broadcast:
{
PRIntn value = (data->value.reuse_addr) ? 1 : 0;
rv = setsockopt(
@@ -2865,6 +2867,39 @@ static PRIOMethods _pr_file_methods = {
(PRSetsocketoptionFN)_PR_InvalidStatus
};
+static PRIOMethods _pr_pipe_methods = {
+ PR_DESC_PIPE,
+ pt_Close,
+ pt_Read,
+ pt_Write,
+ pt_Available_s,
+ pt_Available64_s,
+ pt_Fsync,
+ (PRSeekFN)_PR_InvalidInt,
+ (PRSeek64FN)_PR_InvalidInt64,
+ (PRFileInfoFN)_PR_InvalidStatus,
+ (PRFileInfo64FN)_PR_InvalidStatus,
+ (PRWritevFN)_PR_InvalidInt,
+ (PRConnectFN)_PR_InvalidStatus,
+ (PRAcceptFN)_PR_InvalidDesc,
+ (PRBindFN)_PR_InvalidStatus,
+ (PRListenFN)_PR_InvalidStatus,
+ (PRShutdownFN)_PR_InvalidStatus,
+ (PRRecvFN)_PR_InvalidInt,
+ (PRSendFN)_PR_InvalidInt,
+ (PRRecvfromFN)_PR_InvalidInt,
+ (PRSendtoFN)_PR_InvalidInt,
+ pt_Poll,
+ (PRAcceptreadFN)_PR_InvalidInt,
+ (PRTransmitfileFN)_PR_InvalidInt,
+ (PRGetsocknameFN)_PR_InvalidStatus,
+ (PRGetpeernameFN)_PR_InvalidStatus,
+ (PRGetsockoptFN)_PR_InvalidStatus,
+ (PRSetsockoptFN)_PR_InvalidStatus,
+ (PRGetsocketoptionFN)_PR_InvalidStatus,
+ (PRSetsocketoptionFN)_PR_InvalidStatus
+};
+
static PRIOMethods _pr_tcp_methods = {
PR_DESC_SOCKET_TCP,
pt_Close,
@@ -3017,6 +3052,9 @@ static PRFileDesc *pt_SetMethods(PRIntn osfd, PRDescType type)
flags |= _PR_FCNTL_FLAGS;
(void)fcntl(osfd, F_SETFL, flags);
break;
+ case PR_DESC_PIPE:
+ fd->methods = PR_GetPipeMethods();
+ break;
default:
break;
}
@@ -3029,6 +3067,11 @@ PR_IMPLEMENT(const PRIOMethods*) PR_GetFileMethods()
return &_pr_file_methods;
} /* PR_GetFileMethods */
+PR_IMPLEMENT(const PRIOMethods*) PR_GetPipeMethods()
+{
+ return &_pr_pipe_methods;
+} /* PR_GetFileMethods */
+
PR_IMPLEMENT(const PRIOMethods*) PR_GetTCPMethods()
{
return &_pr_tcp_methods;
@@ -3658,7 +3701,7 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe(
PR_SetError(PR_UNKNOWN_ERROR, errno);
return PR_FAILURE;
}
- *readPipe = pt_SetMethods(pipefd[0], PR_DESC_FILE);
+ *readPipe = pt_SetMethods(pipefd[0], PR_DESC_PIPE);
if (NULL == *readPipe)
{
close(pipefd[0]);
@@ -3668,7 +3711,7 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe(
flags = fcntl(pipefd[0], F_GETFL, 0);
flags |= _PR_FCNTL_FLAGS;
(void)fcntl(pipefd[0], F_SETFL, flags);
- *writePipe = pt_SetMethods(pipefd[1], PR_DESC_FILE);
+ *writePipe = pt_SetMethods(pipefd[1], PR_DESC_PIPE);
if (NULL == *writePipe)
{
PR_Close(*readPipe);
diff --git a/pr/src/pthreads/ptthread.c b/pr/src/pthreads/ptthread.c
index 62e3452d..81375fa6 100644
--- a/pr/src/pthreads/ptthread.c
+++ b/pr/src/pthreads/ptthread.c
@@ -593,7 +593,7 @@ PR_IMPLEMENT(PRThreadPriority) PR_GetThreadPriority(const PRThread *thred)
PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri)
{
- PRIntn rv;
+ PRIntn rv = -1;
PR_ASSERT(NULL != thred);
@@ -605,7 +605,6 @@ PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri
#if defined(_PR_DCETHREADS)
rv = pthread_setprio(thred->id, pt_PriorityMap(newPri));
/* pthread_setprio returns the old priority */
- PR_ASSERT(-1 != rv);
#elif defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
if (EPERM != pt_schedpriv)
{
@@ -613,19 +612,23 @@ PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri
struct sched_param schedule;
rv = pthread_getschedparam(thred->id, &policy, &schedule);
- PR_ASSERT(0 == rv);
- schedule.sched_priority = pt_PriorityMap(newPri);
- rv = pthread_setschedparam(thred->id, policy, &schedule);
- if (EPERM == rv)
- {
- pt_schedpriv = EPERM;
- PR_LOG(_pr_thread_lm, PR_LOG_MIN,
- ("PR_SetThreadPriority: no thread scheduling privilege"));
- }
+ if(0 == rv) {
+ schedule.sched_priority = pt_PriorityMap(newPri);
+ rv = pthread_setschedparam(thred->id, policy, &schedule);
+ if (EPERM == rv)
+ {
+ pt_schedpriv = EPERM;
+ PR_LOG(_pr_thread_lm, PR_LOG_MIN,
+ ("PR_SetThreadPriority: no thread scheduling privilege"));
+ }
+ }
+ if (rv != 0)
+ rv = -1;
}
#endif
- thred->priority = newPri;
+ if (rv != -1)
+ thred->priority = newPri;
} /* PR_SetThreadPriority */
#if 0
diff --git a/pr/src/threads/prrwlock.c b/pr/src/threads/prrwlock.c
index db48e480..9440cd90 100644
--- a/pr/src/threads/prrwlock.c
+++ b/pr/src/threads/prrwlock.c
@@ -249,7 +249,6 @@ int err;
PR_IMPLEMENT(void)
PR_RWLock_Wlock(PRRWLock *rwlock)
{
-PRInt32 lock_acquired = 0;
#if defined(DEBUG)
PRThread *me = PR_GetCurrentThread();
#endif
diff --git a/pr/tests/Makefile b/pr/tests/Makefile
index 49a5bf61..df376580 100644
--- a/pr/tests/Makefile
+++ b/pr/tests/Makefile
@@ -57,6 +57,7 @@ CSRCS = \
dtoa.c \
errcodes.c \
exit.c \
+ fdcach.c \
fileio.c \
foreign.c \
forktest.c \
@@ -267,7 +268,8 @@ endif
ifeq ($(OS_ARCH), HP-UX)
LDOPTS += -z -Wl,+s,+b,$(ABSOLUTE_LIB_DIR)
ifeq ($(USE_64),1)
- LDOPTS += -L/usr/lib/pa20_64 -lpthread +DD64
+ LDOPTS += +DA2.0W
+ EXTRA_LIBS = -lpthread
endif
endif
diff --git a/pr/tests/cltsrv.c b/pr/tests/cltsrv.c
index a2cf5def..266dc552 100644
--- a/pr/tests/cltsrv.c
+++ b/pr/tests/cltsrv.c
@@ -765,6 +765,7 @@ static void PR_CALLBACK Server(void *arg)
server->listener = PR_Socket(domain, SOCK_STREAM, protocol);
+ memset(&serverAddress, 0, sizeof(serverAddress));
rv = PR_InitializeNetAddr(PR_IpAddrAny, DEFAULT_PORT, &serverAddress);
rv = PR_Bind(server->listener, &serverAddress);
diff --git a/pr/tests/pipeping.c b/pr/tests/pipeping.c
index 18501f4f..7c51cf11 100644
--- a/pr/tests/pipeping.c
+++ b/pr/tests/pipeping.c
@@ -66,6 +66,11 @@ int main()
exit(1);
}
+ status = PR_SetFDInheritable(in_pipe[0], PR_FALSE);
+ if (status == PR_FAILURE) {
+ fprintf(stderr, "PR_SetFDInheritable failed\n");
+ exit(1);
+ }
status = PR_SetFDInheritable(in_pipe[1], PR_TRUE);
if (status == PR_FAILURE) {
fprintf(stderr, "PR_SetFDInheritable failed\n");
@@ -76,6 +81,11 @@ int main()
fprintf(stderr, "PR_SetFDInheritable failed\n");
exit(1);
}
+ status = PR_SetFDInheritable(out_pipe[1], PR_FALSE);
+ if (status == PR_FAILURE) {
+ fprintf(stderr, "PR_SetFDInheritable failed\n");
+ exit(1);
+ }
attr = PR_NewProcessAttr();
if (attr == NULL) {
diff --git a/pr/tests/poll_nm.c b/pr/tests/poll_nm.c
index b2a5d34a..27937b62 100644
--- a/pr/tests/poll_nm.c
+++ b/pr/tests/poll_nm.c
@@ -162,6 +162,7 @@ int main(int argc, char **argv)
failed_already=1;
goto exit_now;
}
+ memset(&addr, 0, sizeof(addr));
addr.inet.family = PR_AF_INET;
addr.inet.ip = PR_htonl(PR_INADDR_ANY);
addr.inet.port = PR_htons(0);
diff --git a/pr/tests/poll_to.c b/pr/tests/poll_to.c
index 76942362..a24deac1 100644
--- a/pr/tests/poll_to.c
+++ b/pr/tests/poll_to.c
@@ -105,6 +105,7 @@ int main(int argc, char **argv)
if (!debug_mode) failed_already=1;
goto exit_now;
}
+ memset(&addr, 0, sizeof(addr));
addr.inet.family = PR_AF_INET;
addr.inet.ip = PR_htonl(PR_INADDR_ANY);
addr.inet.port = PR_htons(0);
diff --git a/pr/tests/provider.c b/pr/tests/provider.c
index 9dfd505e..b2a05283 100644
--- a/pr/tests/provider.c
+++ b/pr/tests/provider.c
@@ -934,6 +934,7 @@ static void PR_CALLBACK Server(void *arg)
server->listener = PR_Socket(domain, SOCK_STREAM, protocol);
+ memset(&serverAddress, 0, sizeof(serverAddress));
rv = PR_InitializeNetAddr(PR_IpAddrAny, DEFAULT_PORT, &serverAddress);
rv = PR_Bind(server->listener, &serverAddress);
diff --git a/pr/tests/runtests.ksh b/pr/tests/runtests.ksh
index 64148079..9e1b5e64 100755
--- a/pr/tests/runtests.ksh
+++ b/pr/tests/runtests.ksh
@@ -83,6 +83,7 @@ dlltest
dtoa
errcodes
exit
+fdcach
fileio
foreign
fsync
@@ -162,6 +163,8 @@ version
writev
xnotify"
+rval=0
+
OBJDIR=`basename $PWD`
echo "\nNSPR Test Results - $OBJDIR\n"
echo "BEGIN\t\t\t`date`"
@@ -176,7 +179,10 @@ if [ 0 = $? ] ; then
echo "\t\t\tPassed";
else
echo "\t\t\tFAILED";
+ rval=1
fi;
echo "\nEND TEST: $prog\n" >> ${LOGFILE} 2>&1
done
echo "END\t\t\t`date`"
+
+exit $rval
diff --git a/pr/tests/sigpipe.c b/pr/tests/sigpipe.c
index f40b84cf..b0d267ad 100644
--- a/pr/tests/sigpipe.c
+++ b/pr/tests/sigpipe.c
@@ -66,6 +66,7 @@ int main()
fprintf(stderr, "write to broken pipe failed but with wrong errno: %d\n", errno);
exit(1);
}
+ close(pipefd[1]);
printf("write to broken pipe failed with EPIPE, as expected\n");
printf("PASSED\n");
return 0;
diff --git a/pr/tests/sockopt.c b/pr/tests/sockopt.c
index 7162960e..75eb5d0b 100644
--- a/pr/tests/sockopt.c
+++ b/pr/tests/sockopt.c
@@ -84,6 +84,7 @@ PRIntn main(PRIntn argc, char *argv)
"PR_SockOpt_NoDelay", /* don't delay send to coalesce packets */
"PR_SockOpt_MaxSegment", /* maximum segment size */
+ "PR_SockOpt_Broadcast", /* Enable broadcast */
"PR_SockOpt_Last"
};
@@ -143,6 +144,10 @@ PRIntn main(PRIntn argc, char *argv)
value = &ttl;
size = &ttlsize;
break;
+ case PR_SockOpt_Broadcast:
+ value = &boolean;
+ size = &booleansize;
+ break;
case PR_SockOpt_IpTypeOfService: /* type of service and precedence */
case PR_SockOpt_AddMember: /* add an IP group membership */
case PR_SockOpt_DropMember: /* drop an IP group membership */
@@ -218,6 +223,10 @@ PRIntn main(PRIntn argc, char *argv)
data.value.max_segment = segment;
break;
#endif
+ case PR_SockOpt_Broadcast:
+ fd = udp;
+ data.value.broadcast = PR_TRUE;
+ break;
default: continue;
}
@@ -239,6 +248,8 @@ PRIntn main(PRIntn argc, char *argv)
rv = PR_GetSocketOption(fd, &data);
if (PR_FAILURE == rv) Failed("PR_GetSocketOption()", tag[option]);
}
+ PR_Close(udp);
+ PR_Close(tcp);
}
#ifndef XP_MAC
PR_fprintf(err, "%s\n", (failed) ? "FAILED" : "PASSED");
diff --git a/pr/tests/sockping.c b/pr/tests/sockping.c
index 375415e5..bdc987c4 100644
--- a/pr/tests/sockping.c
+++ b/pr/tests/sockping.c
@@ -59,6 +59,12 @@ int main()
exit(1);
}
+ status = PR_SetFDInheritable(sock[0], PR_FALSE);
+ if (status == PR_FAILURE) {
+ fprintf(stderr, "PR_SetFDInheritable failed: (%d, %d)\n",
+ PR_GetError(), PR_GetOSError());
+ exit(1);
+ }
status = PR_SetFDInheritable(sock[1], PR_TRUE);
if (status == PR_FAILURE) {
fprintf(stderr, "PR_SetFDInheritable failed: (%d, %d)\n",
diff --git a/pr/tests/stack.c b/pr/tests/stack.c
index afad51ff..81422e07 100644
--- a/pr/tests/stack.c
+++ b/pr/tests/stack.c
@@ -41,7 +41,9 @@ typedef struct _DataRecord {
#define MAX_THREAD_CNT 100
#define DEFAULT_THREAD_CNT 4
-#define DEFAULT_DATA_CNT 4
+#define DEFAULT_DATA_CNT 100
+#define DEFAULT_LOOP_CNT 10000
+
/*
* sum of the first n numbers using the formula n*(n+1)/2
*/
@@ -52,6 +54,7 @@ typedef struct stack_data {
PRStack *list2;
PRInt32 initial_data_value;
PRInt32 data_cnt;
+ PRInt32 loops;
} stack_data;
static void stackop(void *arg);
@@ -71,11 +74,12 @@ PRIntn main(PRIntn argc, char **argv)
PRInt32 thread_cnt = DEFAULT_THREAD_CNT;
PRInt32 data_cnt = DEFAULT_DATA_CNT;
+ PRInt32 loops = DEFAULT_LOOP_CNT;
PRThread **threads;
stack_data *thread_args;
PLOptStatus os;
- PLOptState *opt = PL_CreateOptState(argc, argv, "dt:c:");
+ PLOptState *opt = PL_CreateOptState(argc, argv, "dt:c:l:");
while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
{
@@ -91,6 +95,9 @@ PRIntn main(PRIntn argc, char **argv)
case 'c': /* data count */
data_cnt = atoi(opt->value);
break;
+ case 'l': /* loop count */
+ loops = atoi(opt->value);
+ break;
default:
break;
}
@@ -127,6 +134,7 @@ PRIntn main(PRIntn argc, char **argv)
thread_args[cnt].list1 = list1;
thread_args[cnt].list2 = list2;
+ thread_args[cnt].loops = loops;
thread_args[cnt].data_cnt = data_cnt;
thread_args[cnt].initial_data_value = 1 + cnt * data_cnt;
@@ -211,7 +219,7 @@ PRIntn main(PRIntn argc, char **argv)
static void stackop(void *thread_arg)
{
- PRInt32 val, cnt, index;
+ PRInt32 val, cnt, index, loops;
DataRecord *Items, *Item;
PRStack *list1, *list2;
PRStackElem *node;
@@ -219,6 +227,7 @@ static void stackop(void *thread_arg)
val = arg->initial_data_value;
cnt = arg->data_cnt;
+ loops = arg->loops;
list1 = arg->list1;
list2 = arg->list2;
@@ -245,6 +254,22 @@ static void stackop(void *thread_arg)
}
/*
+ * pop data records from list1 and add them back to list1
+ * generates contention for the stack accesses
+ */
+ while (loops-- > 0) {
+ cnt = arg->data_cnt;
+ while (cnt-- > 0) {
+ node = PR_StackPop(list1);
+ if (node == NULL) {
+ PR_fprintf(errhandle, "Error - PR_StackPop returned NULL\n");
+ PR_ASSERT(node != NULL);
+ PR_ProcessExit(3);
+ }
+ PR_StackPush(list1, node);
+ }
+ }
+ /*
* remove the data records from list1 and add them to list2
*/
cnt = arg->data_cnt;