Update with post-3.5 fixes on the tip
authorsrinivas%netscape.com
Tue, 19 Oct 1999 00:40:39 +0000
changeset 886 c5c9c336ce10d3e85562b408d64a9ab64358bc93
parent 885 3281913f9684e5f29d98a2f5aa2732a485347fac
child 887 5c554849871ecf7aa5abf94cb299d8159197b118
push idunknown
push userunknown
push dateunknown
Update with post-3.5 fixes on the tip
config/Makefile
lib/ds/plvrsion.c
lib/libc/src/plvrsion.c
lib/prstreams/plvrsion.c
pr/include/md/_pcos.h
pr/include/md/_unixos.h
pr/include/prio.h
pr/include/private/pprio.h
pr/include/private/primpl.h
pr/src/io/prfdcach.c
pr/src/io/prfile.c
pr/src/io/prlayer.c
pr/src/io/prmapopt.c
pr/src/md/mac/macsocket.h
pr/src/md/unix/Makefile
pr/src/md/unix/objs.mk
pr/src/md/unix/unix.c
pr/src/md/unix/uxpoll.c
pr/src/md/windows/ntmisc.c
pr/src/md/windows/w95io.c
pr/src/misc/prsystem.c
pr/src/prvrsion.c
pr/src/pthreads/ptio.c
pr/src/pthreads/ptthread.c
pr/src/threads/prrwlock.c
pr/tests/Makefile
pr/tests/cltsrv.c
pr/tests/pipeping.c
pr/tests/poll_nm.c
pr/tests/poll_to.c
pr/tests/provider.c
pr/tests/runtests.ksh
pr/tests/sigpipe.c
pr/tests/sockopt.c
pr/tests/sockping.c
pr/tests/stack.c
--- a/config/Makefile
+++ b/config/Makefile
@@ -55,17 +55,17 @@ ifeq ($(OS_ARCH), IRIX)
 			    XLDOPTS += -32
 		    endif
 	    endif
     endif
 endif
 
 ifeq ($(OS_ARCH), HP-UX)
     ifeq ($(USE_64),1)
-        XLDOPTS += +DD64
+        XLDOPTS += +DA2.0W
     endif
 endif
 
 ifdef XP_OS2_EMX
 XCFLAGS = $(OS_EXE_CFLAGS)
 XLDOPTS = -Zlinker /PM:VIO
 endif
 
--- a/lib/ds/plvrsion.c
+++ b/lib/ds/plvrsion.c
@@ -64,18 +64,21 @@ static PRVersionDescription prVersionDes
     /* comment          */  "http://www.mozilla.org/NPL/",
     /* specialString    */ ""
 };
 
 #ifdef XP_UNIX
 
 /*
  * 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;
 
 #endif /* XP_UNIX */
 
 PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
 {
--- a/lib/libc/src/plvrsion.c
+++ b/lib/libc/src/plvrsion.c
@@ -64,18 +64,21 @@ static PRVersionDescription prVersionDes
     /* comment          */  "http://www.mozilla.org/NPL/",
     /* specialString    */ ""
 };
 
 #ifdef XP_UNIX
 
 /*
  * 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;
 
 #endif /* XP_UNIX */
 
 PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
 {
--- a/lib/prstreams/plvrsion.c
+++ b/lib/prstreams/plvrsion.c
@@ -64,18 +64,21 @@ static PRVersionDescription prVersionDes
     /* comment          */  "http://www.mozilla.org/NPL/",
     /* specialString    */ ""
 };
 
 #ifdef XP_UNIX
 
 /*
  * 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;
 
 #endif /* XP_UNIX */
 
 PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
 {
--- a/pr/include/md/_pcos.h
+++ b/pr/include/md/_pcos.h
@@ -58,11 +58,13 @@ PR_END_EXTERN_C
 #include <fcntl.h>          /* O_BINARY */
 
 #ifdef OS2
 extern PRStatus _MD_OS2GetHostName(char *name, PRUint32 namelen);
 #define _MD_GETHOSTNAME _MD_OS2GetHostName
 #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___ */
--- a/pr/include/md/_unixos.h
+++ b/pr/include/md/_unixos.h
@@ -388,16 +388,18 @@ extern PRInt32		_MD_writev(PRFileDesc *f
 								PRInt32 iov_size, PRIntervalTime timeout);
 #define _MD_WRITEV	_MD_writev
 
 extern PRInt32		_MD_socketavailable(PRFileDesc *fd);
 #define	_MD_SOCKETAVAILABLE		_MD_socketavailable
 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
 
 extern PRInt32		_MD_close(PRInt32 osfd);
 #define _MD_CLOSE_FILE	_MD_close
 extern PRInt32		_MD_lseek(PRFileDesc*, PRInt32, PRSeekWhence);
 #define _MD_LSEEK	_MD_lseek
@@ -430,16 +432,19 @@ extern PRStatus _MD_setsockopt(PRFileDes
 #define _MD_SETSOCKOPT		_MD_setsockopt
 
 extern PRStatus _MD_set_fd_inheritable(PRFileDesc *fd, PRBool inheritable);
 #define _MD_SET_FD_INHERITABLE _MD_set_fd_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
 #define HAVE_SOCKET_KEEPALIVE
 
 /* Memory-mapped files */
 
 struct _MDFileMap {
--- a/pr/include/prio.h
+++ b/pr/include/prio.h
@@ -214,16 +214,17 @@ typedef enum PRSockOption
     PR_SockOpt_AddMember,       /* add an IP group membership */
     PR_SockOpt_DropMember,      /* drop an IP group membership */
     PR_SockOpt_McastInterface,  /* multicast interface address */
     PR_SockOpt_McastTimeToLive, /* multicast timetolive */
     PR_SockOpt_McastLoopback,   /* multicast loopback */
 
     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;
 
 typedef struct PRLinger {
 	PRBool polarity;		    /* Polarity of the option's setting */
 	PRIntervalTime linger;	    /* Time to linger before closing */
 } PRLinger;
 
@@ -240,16 +241,17 @@ typedef struct PRSocketOptionData
         PRUintn ip_ttl;             /* IP time to live */
         PRUintn mcast_ttl;          /* IP multicast time to live */
         PRUintn tos;                /* IP type of service and precedence */
         PRBool non_blocking;        /* Non-blocking (network) I/O */
         PRBool reuse_addr;          /* Allow local address reuse */
         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 */
         PRLinger linger;            /* Time to linger on close if data present */
         PRMcastRequest add_member;  /* add an IP group membership */
         PRMcastRequest drop_member; /* Drop an IP group membership */
         PRNetAddr mcast_if;         /* multicast interface address */
     } value;
@@ -273,17 +275,18 @@ typedef struct PRIOVec {
 ** Discover what type of socket is being described by the file descriptor.
 ***************************************************************************
 */
 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 {
     PR_SEEK_SET = 0,
     PR_SEEK_CUR = 1,
     PR_SEEK_END = 2
 } PRSeekWhence;
 
--- a/pr/include/private/pprio.h
+++ b/pr/include/private/pprio.h
@@ -25,39 +25,24 @@
 #ifndef pprio_h___
 #define pprio_h___
 
 #include "prtypes.h"
 #include "prio.h"
 
 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
-
 /************************************************************************/
 /************************************************************************/
 
 /* Return the method tables for files, tcp sockets and udp sockets */
 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.
 ** This function will be obsoleted with the next release; avoid using it.
 */
 PR_EXTERN(PRInt32)      PR_FileDesc2NativeHandle(PRFileDesc *);
 PR_EXTERN(void)         PR_ChangeFileDescNativeHandle(PRFileDesc *, PRInt32);
 PR_EXTERN(PRFileDesc*)  PR_AllocFileDesc(PRInt32 osfd,
--- a/pr/include/private/primpl.h
+++ b/pr/include/private/primpl.h
@@ -1160,16 +1160,19 @@ extern PRInt32 _PR_MD_SOCKETPAIR(int af,
 #define    _PR_MD_SOCKETPAIR _MD_SOCKETPAIR
 
 extern PRInt32 _PR_MD_SOCKET(int af, int type, int flags);
 #define    _PR_MD_SOCKET _MD_SOCKET
 
 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
 
 extern PRStatus _PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable);
 #define    _PR_MD_SET_FD_INHERITABLE _MD_SET_FD_INHERITABLE
 
 
@@ -1498,16 +1501,32 @@ struct PRProcess {
 struct PRFileMap {
     PRFileDesc *fd;
     PRFileMapProtect prot;
     _MDFileMap md;
 };
 
 /************************************************************************/
 
+/*
+** 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;
     PRBool inheritable;
     PRFileDesc *next;
     PRIntn lockCount;
     _MDFileDesc md;
 #ifdef _PR_PTHREADS
@@ -1871,16 +1890,19 @@ extern PRStatus _PR_MakeNativeIPCName(
 
 PR_EXTERN(PRInt32) _PR_MD_GET_SOCKET_ERROR(void);
 #define    _PR_MD_GET_SOCKET_ERROR _MD_GET_SOCKET_ERROR
 
 /* Get name of current host */
 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;
 
 typedef struct _ConnectListNode {
 	PRInt32		osfd;
 	PRNetAddr	addr;
 	PRUint32	addrlen;
--- a/pr/src/io/prfdcach.c
+++ b/pr/src/io/prfdcach.c
@@ -12,17 +12,16 @@
  * 
  * The Initial Developer of this code under the NPL is Netscape
  * Communications Corporation.  Portions created by Netscape are
  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  * Reserved.
  */
 
 #include "primpl.h"
-#include "pratom.h"
 
 #include <string.h>
 
 /*****************************************************************************/
 /*****************************************************************************/
 /************************** File descriptor caching **************************/
 /*****************************************************************************/
 /*****************************************************************************/
@@ -177,16 +176,18 @@ void _PR_Putfd(PRFileDesc *fd)
 
 PR_IMPLEMENT(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high)
 {
     /*
     ** This can be called at any time, may adjust the cache sizes,
     ** 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);
     if (0 == high)  /* shutting down or staying down */
     {
         if (0 != _pr_fd_cache.limit_high)  /* shutting down */
         {
             _pr_fd_cache.limit_high = 0;  /* stop use */
@@ -196,38 +197,39 @@ PR_IMPLEMENT(PRStatus) PR_SetFDCacheSize
             ** let that happen.
             **
             ** Put all the cached fds onto the new cache.
             */
             while (NULL != _pr_fd_cache.head)
             {
                 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;
             _pr_fd_cache.count = 0;
         }
     }
     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;
             }
         }
     }
     PR_Unlock(_pr_fd_cache.ml);
     return PR_SUCCESS;
 }  /* PR_SetFDCacheSize */
 
 void _PR_InitFdCache()
@@ -236,30 +238,31 @@ void _PR_InitFdCache()
     ** The fd caching is enabled by default for DEBUG builds,
     ** disabled by default for OPT builds. That default can
     ** be overridden at runtime using environment variables
     ** or a super-wiz-bang API.
     */
     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;
 
     _pr_fd_cache.ml = PR_NewLock();
     PR_ASSERT(NULL != _pr_fd_cache.ml);
     _pr_fd_cache.stack = PR_CreateStack("FD");
     PR_ASSERT(NULL != _pr_fd_cache.stack);
 
--- a/pr/src/io/prfile.c
+++ b/pr/src/io/prfile.c
@@ -150,16 +150,30 @@ static PRInt64 PR_CALLBACK FileAvailable
     if (!LL_GE_ZERO(cur) || !LL_GE_ZERO(end)) return minus_one;
 
     LL_SUB(result, end, cur);
     (void)_PR_MD_LSEEK64(fd, cur, PR_SEEK_SET);
 
     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;
 
     rv = _PR_MD_GETOPENFILEINFO(fd, info);
     if (rv < 0) {
 	return PR_FAILURE;
     } else
@@ -251,16 +265,54 @@ static PRIOMethods _pr_fileMethods = {
     (PRSetsocketoptionFN)_PR_InvalidStatus
 };
 
 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;
     PRFileDesc *fd = 0;
 
     if (!_pr_initialized) _PR_ImplicitInitialization();
 
     /* Map pr open flags and mode to os specific flags */
@@ -548,23 +600,23 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe(
 
     ZeroMemory(&pipeAttributes, sizeof(pipeAttributes));
     pipeAttributes.nLength = sizeof(pipeAttributes);
     pipeAttributes.bInheritHandle = TRUE;
     if (CreatePipe(&readEnd, &writeEnd, &pipeAttributes, 0) == 0) {
         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);
         return PR_FAILURE;
     }
 #ifdef WINNT
     (*readPipe)->secret->md.sync_file_io = PR_TRUE;
     (*writePipe)->secret->md.sync_file_io = PR_TRUE;
@@ -577,23 +629,23 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe(
 
     if (!_pr_initialized) _PR_ImplicitInitialization();
 
     if (pipe(pipefd) == -1) {
         /* XXX map pipe error */
         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]);
         return PR_FAILURE;
     }
     _MD_MakeNonblock(*readPipe);
     _MD_MakeNonblock(*writePipe);
     return PR_SUCCESS;
--- a/pr/src/io/prlayer.c
+++ b/pr/src/io/prlayer.c
@@ -38,27 +38,30 @@ void PR_CALLBACK pl_FDDestructor(PRFileD
     PR_DELETE(fd);
 }
 
 /*
 ** Default methods that just call down to the next 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)
 {
     PR_ASSERT(fd != NULL);
     PR_ASSERT(fd->lower != NULL);
 
     return (fd->lower->methods->read)(fd->lower, buf, amount);
--- a/pr/src/io/prmapopt.c
+++ b/pr/src/io/prmapopt.c
@@ -87,16 +87,17 @@ PRStatus PR_CALLBACK _PR_SocketGetSocket
 #else
                 PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
                 return PR_FAILURE;
 #endif
             }
             case PR_SockOpt_Reuseaddr:
             case PR_SockOpt_Keepalive:
             case PR_SockOpt_NoDelay:
+            case PR_SockOpt_Broadcast:
             {
 #ifdef WIN32 /* Winsock */
                 BOOL value;
 #else
                 PRIntn value;
 #endif
                 length = sizeof(value);
                 rv = _PR_MD_GETSOCKOPT(
@@ -237,16 +238,17 @@ PRStatus PR_CALLBACK _PR_SocketSetSocket
 #else
                 PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
                 return PR_FAILURE;
 #endif
             }
             case PR_SockOpt_Reuseaddr:
             case PR_SockOpt_Keepalive:
             case PR_SockOpt_NoDelay:
+            case PR_SockOpt_Broadcast:
             {
 #ifdef WIN32 /* Winsock */
                 BOOL value;
 #else
                 PRIntn value;
 #endif
                 value = (data->value.reuse_addr) ? 1 : 0;
                 rv = _PR_MD_SETSOCKOPT(
@@ -449,24 +451,24 @@ PRStatus PR_CALLBACK _PR_SocketSetSocket
 PRStatus _PR_MapOptionName(
     PRSockOption optname, PRInt32 *level, PRInt32 *name)
 {
     static PRInt32 socketOptions[PR_SockOpt_Last] =
     {
         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)
     && (optname > PR_SockOpt_MaxSegment))
     {
         PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
         return PR_FAILURE;
     }
--- a/pr/src/md/mac/macsocket.h
+++ b/pr/src/md/mac/macsocket.h
@@ -75,16 +75,17 @@ struct	hostent {
 #define FIONBIO 1
 #define SOCK_STREAM 1
 #define SOCK_DGRAM 		2
 #define IPPROTO_TCP 	INET_TCP		// Default TCP protocol
 #define IPPROTO_UDP		INET_UDP		// Default UDP protocol
 #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;
 
 /* ldap.h has its own definition of fd_set */
 /* select support */
 #if !defined(FD_SET)
 #define	NBBY    8
--- a/pr/src/md/unix/Makefile
+++ b/pr/src/md/unix/Makefile
@@ -25,21 +25,24 @@ ifeq ($(OS_RELEASE),4.1.3_U1)
 OPTIMIZER =
 endif
 endif
 
 CSRCS =          \
 	unix.c    \
 	unix_errors.c    \
 	uxproces.c \
+	uxshm.c \
 	uxwrap.c \
-	uxpoll.c \
-	uxshm.c \
 	$(NULL)
 
+ifneq ($(USE_PTHREADS),1)
+CSRCS += uxpoll.c
+endif
+
 PTH_USER_CSRCS =          \
 	pthreads_user.c \
 	$(NULL)
 
 IRIX_CSRCS =	 \
 	irix.c	 \
 	$(NULL)
 
--- a/pr/src/md/unix/objs.mk
+++ b/pr/src/md/unix/objs.mk
@@ -19,19 +19,22 @@
 # object modules that will be part of the nspr20 library.
 
 CSRCS =          \
 	unix.c    \
 	unix_errors.c \
 	uxproces.c \
 	uxshm.c \
 	uxwrap.c \
-	uxpoll.c \
 	$(NULL)
 
+ifneq ($(USE_PTHREADS),1)
+CSRCS += uxpoll.c
+endif
+
 PTH_USER_CSRCS =          \
 	pthreads_user.c \
 	$(NULL)
 
 ifdef USE_AUTOCONF
 
 CSRCS	+= $(PR_MD_CSRCS)
 ASFILES += $(PR_MD_ASFILES)
--- a/pr/src/md/unix/unix.c
+++ b/pr/src/md/unix/unix.c
@@ -22,16 +22,18 @@
 #include <signal.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #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>
 #endif
 
 /* To get FIONREAD */
 #if defined(NCR) || defined(UNIXWARE) || defined(NEC) || defined(SNI) \
         || defined(SONY)
@@ -3686,16 +3688,35 @@ PR_IMPLEMENT(PRStatus) _MD_gethostname(c
     rv = gethostname(name, namelen);
     if (0 == rv) {
         return PR_SUCCESS;
     }
     _PR_MD_MAP_GETHOSTNAME_ERROR(_MD_ERRNO());
     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;
+}
+
 /*
  *******************************************************************
  *
  * Memory-mapped files
  *
  *******************************************************************
  */
 
--- a/pr/src/md/unix/uxpoll.c
+++ b/pr/src/md/unix/uxpoll.c
@@ -13,18 +13,17 @@
  * The Initial Developer of this code under the NPL is Netscape
  * Communications Corporation.  Portions created by Netscape are
  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  * Reserved.
  */
 
 #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) */
 
 #include "primpl.h"
 
 #include <sys/time.h>
 
 #include <fcntl.h>
@@ -676,10 +675,10 @@ PRInt32 _MD_pr_poll(PRPollDesc *pds, PRI
         rv = NativeThreads(pds, npds, timeout);
     else rv = LocalThreads(pds, npds, timeout);
 
     return rv;
 }  /* _MD_pr_poll */
 
 #endif  /* defined(_PR_PTHREADS) */               
 
-/* pruxpoll.c */
+/* uxpoll.c */
 
--- a/pr/src/md/windows/ntmisc.c
+++ b/pr/src/md/windows/ntmisc.c
@@ -546,16 +546,85 @@ PRStatus _MD_WindowsGetHostName(char *na
         return PR_SUCCESS;
     }
     syserror = WSAGetLastError();
     PR_ASSERT(WSANOTINITIALISED != syserror);
 	_PR_MD_MAP_GETHOSTNAME_ERROR(syserror);
     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;
+}
+
 /*
  **********************************************************************
  *
  * Memory-mapped files
  *
  **********************************************************************
  */
 
--- a/pr/src/md/windows/w95io.c
+++ b/pr/src/md/windows/w95io.c
@@ -869,76 +869,52 @@ PRInt32
 		_PR_MD_MAP_RMDIR_ERROR(GetLastError());
         return -1;
     }
 }
 
 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() */
 
 
 PRStatus
 _PR_MD_UNLOCKFILE(PRInt32 f)
 {
 	PRInt32   rv;
     
     rv = UnlockFile( (HANDLE) f,
     		0l, 0l,
-            0x7fffffff, 0xffffffff ); 
+            0x0l, 0xffffffffl ); 
             
     if ( rv )
     {
     	return PR_SUCCESS;
     }
     else
     {
-    	int err = GetLastError();
+		_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
 		return PR_FAILURE;
     }
 } /* end _PR_MD_UNLOCKFILE() */
 
--- a/pr/src/misc/prsystem.c
+++ b/pr/src/misc/prsystem.c
@@ -63,27 +63,29 @@ PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(
                     break;
                 }
                 len += 1;
             }    
          break;
 
       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)
         {
             ULONG os2ver[2] = {0};
             DosQuerySysInfo(QSV_VERSION_MINOR, QSV_VERSION_REVISION,
                             &os2ver, sizeof(os2ver));
             /* Formatting for normal usage (2.11, 3.0, 4.0); officially,
                Warp 4 is version 2.40.00 */
@@ -96,11 +98,15 @@ PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(
         }
 #endif /* OS2 */
         break;
 
       case PR_SI_ARCHITECTURE:
         /* 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;
 }
--- a/pr/src/prvrsion.c
+++ b/pr/src/prvrsion.c
@@ -64,18 +64,21 @@ static PRVersionDescription prVersionDes
     /* comment          */  "License information: http://www.mozilla.org/NPL/",
     /* specialString    */ ""
 };
 
 #ifdef XP_UNIX
 
 /*
  * 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;
 
 #endif /* XP_UNIX */
 
 PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint(void)
 {
--- a/pr/src/pthreads/ptio.c
+++ b/pr/src/pthreads/ptio.c
@@ -2634,16 +2634,17 @@ static PRStatus pt_GetSocketOption(PRFil
                     (linger.l_onoff) ? PR_TRUE : PR_FALSE;
                 data->value.linger.linger =
                     PR_SecondsToInterval(linger.l_linger);
                 break;
             }
             case PR_SockOpt_Reuseaddr:
             case PR_SockOpt_Keepalive:
             case PR_SockOpt_NoDelay:
+            case PR_SockOpt_Broadcast:
             {
                 PRIntn value;
                 length = sizeof(PRIntn);
                 rv = getsockopt(
                     fd->secret->md.osfd, level, name, (char*)&value, &length);
                 PR_ASSERT((-1 == rv) || (sizeof(PRIntn) == length));
                 data->value.reuse_addr = (0 == value) ? PR_FALSE : PR_TRUE;
                 break;
@@ -2752,16 +2753,17 @@ static PRStatus pt_SetSocketOption(PRFil
                 linger.l_linger = PR_IntervalToSeconds(data->value.linger.linger);
                 rv = setsockopt(
                     fd->secret->md.osfd, level, name, (char*)&linger, sizeof(linger));
                 break;
             }
             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(
                     fd->secret->md.osfd, level, name,
                     (char*)&value, sizeof(PRIntn));
                 break;
             }
             case PR_SockOpt_McastLoopback:
@@ -2860,16 +2862,49 @@ static PRIOMethods _pr_file_methods = {
     (PRGetsocknameFN)_PR_InvalidStatus,    
     (PRGetpeernameFN)_PR_InvalidStatus,    
     (PRGetsockoptFN)_PR_InvalidStatus,    
     (PRSetsockoptFN)_PR_InvalidStatus,    
     (PRGetsocketoptionFN)_PR_InvalidStatus,
     (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,
     pt_Read,
     pt_Write,
     pt_Available_s,
     pt_Available64_s,
     pt_Synch,
@@ -3012,28 +3047,36 @@ static PRFileDesc *pt_SetMethods(PRIntn 
                     (_PRSockOptVal_t) &one, sizeof(one));
                 break;
             case PR_DESC_SOCKET_UDP:
                 fd->methods = PR_GetUDPMethods();
                 flags = fcntl(osfd, F_GETFL, 0);
                 flags |= _PR_FCNTL_FLAGS;
                 (void)fcntl(osfd, F_SETFL, flags);
                 break;
+            case PR_DESC_PIPE:
+                fd->methods = PR_GetPipeMethods();
+                break;
             default:
                 break;
         }
     }
     return fd;
 }  /* pt_SetMethods */
 
 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;
 }  /* PR_GetTCPMethods */
 
 PR_IMPLEMENT(const PRIOMethods*) PR_GetUDPMethods()
 {
     return &_pr_udp_methods;
@@ -3653,27 +3696,27 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe(
     if (pt_TestAbort()) return PR_FAILURE;
 
     if (pipe(pipefd) == -1)
     {
     /* XXX map pipe error */
         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]);
         close(pipefd[1]);
         return PR_FAILURE;
     }
     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);
         close(pipefd[1]);
         return PR_FAILURE;
     }
     flags = fcntl(pipefd[1], F_GETFL, 0);
     flags |= _PR_FCNTL_FLAGS;
--- a/pr/src/pthreads/ptthread.c
+++ b/pr/src/pthreads/ptthread.c
@@ -588,49 +588,52 @@ PR_IMPLEMENT(PRThreadState) PR_GetThread
 PR_IMPLEMENT(PRThreadPriority) PR_GetThreadPriority(const PRThread *thred)
 {
     PR_ASSERT(thred != NULL);
     return thred->priority;
 }  /* PR_GetThreadPriority */
 
 PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri)
 {
-    PRIntn rv;
+    PRIntn rv = -1;
 
     PR_ASSERT(NULL != thred);
 
     if ((PRIntn)PR_PRIORITY_FIRST > (PRIntn)newPri)
         newPri = PR_PRIORITY_FIRST;
     else if ((PRIntn)PR_PRIORITY_LAST < (PRIntn)newPri)
         newPri = PR_PRIORITY_LAST;
 
 #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)
     {
         int policy;
         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
 PR_IMPLEMENT(PRStatus) PR_NewThreadPrivateIndex(
     PRUintn *newIndex, PRThreadPrivateDTOR destructor)
 {
     int rv;
 
--- a/pr/src/threads/prrwlock.c
+++ b/pr/src/threads/prrwlock.c
@@ -244,17 +244,16 @@ int err;
 }
 
 /*
 ** Write-lock the RWLock.
 */
 PR_IMPLEMENT(void)
 PR_RWLock_Wlock(PRRWLock *rwlock)
 {
-PRInt32 lock_acquired = 0;
 #if defined(DEBUG)
 PRThread *me = PR_GetCurrentThread();
 #endif
 #if defined(HAVE_UNIX98_RWLOCK) || defined(HAVE_UI_RWLOCK)
 int err;
 #endif
 
 #ifdef _PR_RWLOCK_RANK_ORDER_DEBUG
--- a/pr/tests/Makefile
+++ b/pr/tests/Makefile
@@ -52,16 +52,17 @@ CSRCS =             \
 	concur.c	    \
 	cvar.c			\
 	cvar2.c			\
 	dceemu.c		\
 	dlltest.c		\
 	dtoa.c			\
 	errcodes.c		\
 	exit.c  		\
+	fdcach.c		\
 	fileio.c		\
 	foreign.c	    \
 	forktest.c	    \
 	fsync.c	        \
 	gethost.c		\
 	getproto.c		\
 	i2l.c		    \
 	initclk.c		\
@@ -262,17 +263,18 @@ ifeq ($(OS_ARCH), OSF1)
     else
         LDOPTS += -rpath $(ABSOLUTE_LIB_DIR)
     endif
 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
 
 # AIX
 ifeq ($(OS_ARCH),AIX)
     LDOPTS += -blibpath:$(ABSOLUTE_LIB_DIR):/usr/lib:/lib
     ifeq ($(OS_ARCH)$(OS_RELEASE),AIX4.1)
         LIBPR = -lnspr$(MOD_VERSION)_shr
--- a/pr/tests/cltsrv.c
+++ b/pr/tests/cltsrv.c
@@ -760,16 +760,17 @@ static void PR_CALLBACK Server(void *arg
 {
     PRStatus rv;
     PRNetAddr serverAddress;
     PRThread *me = PR_CurrentThread();
     CSServer_t *server = (CSServer_t*)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);
     TEST_ASSERT(PR_SUCCESS == rv);
 
     rv = PR_Listen(server->listener, server->backlog);
     TEST_ASSERT(PR_SUCCESS == rv);
 
--- a/pr/tests/pipeping.c
+++ b/pr/tests/pipeping.c
@@ -61,26 +61,36 @@ int main()
         exit(1);
     }
     status = PR_CreatePipe(&out_pipe[0], &out_pipe[1]);
     if (status == PR_FAILURE) {
         fprintf(stderr, "PR_CreatePipe failed\n");
         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");
         exit(1);
     }
     status = PR_SetFDInheritable(out_pipe[0], PR_TRUE);
     if (status == PR_FAILURE) {
         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) {
         fprintf(stderr, "PR_NewProcessAttr failed\n");
         exit(1);
     }
 
     PR_ProcessAttrSetStdioRedirect(attr, PR_StandardInput, out_pipe[0]);
--- a/pr/tests/poll_nm.c
+++ b/pr/tests/poll_nm.c
@@ -157,16 +157,17 @@ int main(int argc, char **argv)
 	}
 
     /* Create two listening sockets */
     if ((listenSock1 = PR_NewTCPSocket()) == NULL) {
 	fprintf(stderr, "Can't create a new TCP socket\n");
 	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);
     if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {
 	fprintf(stderr, "Can't bind socket\n");
 	failed_already=1;
 	goto exit_now;
     }
--- a/pr/tests/poll_to.c
+++ b/pr/tests/poll_to.c
@@ -100,16 +100,17 @@ int main(int argc, char **argv)
 	}
 
     /* Create two listening sockets */
     if ((listenSock1 = PR_NewTCPSocket()) == NULL) {
 	fprintf(stderr, "Can't create a new TCP socket\n");
 	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);
     if (PR_Bind(listenSock1, &addr) == PR_FAILURE) {
 	fprintf(stderr, "Can't bind socket\n");
 	if (!debug_mode)  failed_already=1;
 	goto exit_now;
     }
--- a/pr/tests/provider.c
+++ b/pr/tests/provider.c
@@ -929,16 +929,17 @@ static void PR_CALLBACK Server(void *arg
 {
     PRStatus rv;
     PRNetAddr serverAddress;
     CSServer_t *server = (CSServer_t*)arg;
     PRThread *me = server->thread = PR_CurrentThread();
 
     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);
     TEST_ASSERT(PR_SUCCESS == rv);
 
     rv = PR_Listen(server->listener, server->backlog);
     TEST_ASSERT(PR_SUCCESS == rv);
 
--- a/pr/tests/runtests.ksh
+++ b/pr/tests/runtests.ksh
@@ -78,16 +78,17 @@ cleanup
 cltsrv
 concur
 cvar
 cvar2
 dlltest
 dtoa
 errcodes
 exit
+fdcach
 fileio
 foreign
 fsync
 gethost
 getproto
 i2l
 initclk
 inrval
@@ -157,26 +158,31 @@ timemac
 timetest
 tpd
 udpsrv
 vercheck
 version
 writev
 xnotify"
 
+rval=0
+
 OBJDIR=`basename $PWD`
 echo "\nNSPR Test Results - $OBJDIR\n"
 echo "BEGIN\t\t\t`date`"
 echo "NSPR_TEST_LOGFILE\t${LOGFILE}\n"
 echo "Test\t\t\tResult\n"
 for prog in $TESTS
 do
 echo "$prog\c"
 echo "\nBEGIN TEST: $prog\n" >> ${LOGFILE} 2>&1
 ./$prog >> ${LOGFILE} 2>&1
 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
--- a/pr/tests/sigpipe.c
+++ b/pr/tests/sigpipe.c
@@ -61,14 +61,15 @@ int main()
     if (rv != -1) {
         fprintf(stderr, "write to broken pipe should have failed with EPIPE but returned %d\n", rv);
         exit(1);
     }
     if (errno != EPIPE) {
         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;
 }
 
 #endif /* XP_UNIX */
--- a/pr/tests/sockopt.c
+++ b/pr/tests/sockopt.c
@@ -79,16 +79,17 @@ PRIntn main(PRIntn argc, char *argv)
         "PR_SockOpt_AddMember",       /* add an IP group membership */
         "PR_SockOpt_DropMember",      /* drop an IP group membership */
         "PR_SockOpt_McastInterface",  /* multicast interface address */
         "PR_SockOpt_McastTimeToLive", /* multicast timetolive */
         "PR_SockOpt_McastLoopback",   /* multicast loopback */
 
         "PR_SockOpt_NoDelay",         /* don't delay send to coalesce packets */
         "PR_SockOpt_MaxSegment",      /* maximum segment size */
+        "PR_SockOpt_Broadcast",       /* Enable broadcast */
         "PR_SockOpt_Last"
     };
 
     err = PR_GetSpecialFD(PR_StandardError);
     PR_STDIO_INIT();
 
 #ifdef XP_MAC
 	SetupMacPrintfLog("sockopt.log");
@@ -138,16 +139,20 @@ PRIntn main(PRIntn argc, char *argv)
                 value = &segment;
                 size = &segmentsize;
                 break;
 
             case PR_SockOpt_IpTimeToLive:    /* time to live */
                 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 */
             case PR_SockOpt_McastInterface:  /* multicast interface address */
             case PR_SockOpt_McastTimeToLive: /* multicast timetolive */
             case PR_SockOpt_McastLoopback:   /* multicast loopback */
             default:
                 continue;
@@ -213,16 +218,20 @@ PRIntn main(PRIntn argc, char *argv)
                 case PR_SockOpt_NoDelay:
                     data.value.no_delay = PR_TRUE;         
                     break;    
 #ifndef WIN32
                 case PR_SockOpt_MaxSegment:
                     data.value.max_segment = segment;      
                     break;    
 #endif
+                case PR_SockOpt_Broadcast:
+                    fd = udp; 
+                    data.value.broadcast = PR_TRUE;         
+                    break;    
                 default: continue;
             }
 
 			/*
 			 * TCP_MAXSEG can only be read, not set
 			 */
             if (option != PR_SockOpt_MaxSegment) {
 #ifdef WIN32
@@ -234,16 +243,18 @@ PRIntn main(PRIntn argc, char *argv)
             		if (PR_FAILURE == rv)
 							Failed("PR_SetSocketOption()", tag[option]);
 				}
 			}
 
             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");
 #else
    printf("%s\n", (failed) ? "FAILED" : "PASSED");
 #endif
     return (failed) ? 1 : 0;
 }  /* main */
--- a/pr/tests/sockping.c
+++ b/pr/tests/sockping.c
@@ -54,16 +54,22 @@ int main()
     int idx;
 
     status = PR_NewTCPSocketPair(sock);
     if (status == PR_FAILURE) {
         fprintf(stderr, "PR_NewTCPSocketPair failed\n");
         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",
                 PR_GetError(), PR_GetOSError());
         exit(1);
     }
 
     attr = PR_NewProcessAttr();
--- a/pr/tests/stack.c
+++ b/pr/tests/stack.c
@@ -36,27 +36,30 @@ typedef struct _DataRecord {
 	PRInt32	data;
 	PRStackElem	link;
 } DataRecord;
 
 #define RECORD_LINK_PTR(lp) ((DataRecord*) ((char*) (lp) - offsetof(DataRecord,link)))
 
 #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
  */
 #define SUM_OF_NUMBERS(n) ((n & 1) ? (((n + 1)/2) * n) : ((n/2) * (n+1)))
 
 typedef struct stack_data {
 	PRStack		*list1;
 	PRStack		*list2;
 	PRInt32		initial_data_value;
 	PRInt32		data_cnt;
+	PRInt32		loops;
 } stack_data;
 
 static void stackop(void *arg);
 
 static int _debug_on;
 
 PRFileDesc  *output;
 PRFileDesc  *errhandle;
@@ -66,36 +69,40 @@ PRIntn main(PRIntn argc, char **argv)
     PRInt32 rv, cnt, sum;
 	DataRecord	*Item;
 	PRStack		*list1, *list2;
 	PRStackElem	*node;
 	PRStatus rc;
 
 	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)))
     {
 		if (PL_OPT_BAD == os) continue;
         switch (opt->option)
         {
         case 'd':  /* debug mode */
 			_debug_on = 1;
             break;
         case 't':  /* thread count */
             thread_cnt = atoi(opt->value);
             break;
         case 'c':  /* data count */
             data_cnt = atoi(opt->value);
             break;
+        case 'l':  /* loop count */
+            loops = atoi(opt->value);
+            break;
          default:
             break;
         }
     }
 	PL_DestroyOptState(opt);
 
 	PR_SetConcurrency(4);
 
@@ -122,16 +129,17 @@ PRIntn main(PRIntn argc, char **argv)
 	if (_debug_on)
 		PR_fprintf(output,"%s: thread_cnt = %d data_cnt = %d\n", argv[0],
 							thread_cnt, data_cnt);
 	for(cnt = 0; cnt < thread_cnt; cnt++) {
 		PRThreadScope scope;
 
 		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;
 
 		if (cnt & 1)
 			scope = PR_GLOBAL_THREAD;
 		else
 			scope = PR_LOCAL_THREAD;
 
@@ -206,24 +214,25 @@ PRIntn main(PRIntn argc, char **argv)
 							argv[0], sum,
 								SUM_OF_NUMBERS(data_cnt * thread_cnt));
 		return 2;
 	}
 }
 
 static void stackop(void *thread_arg)
 {
-    PRInt32 val, cnt, index;
+    PRInt32 val, cnt, index, loops;
 	DataRecord	*Items, *Item;
 	PRStack		*list1, *list2;
 	PRStackElem	*node;
 	stack_data *arg = (stack_data *) thread_arg;
 
 	val = arg->initial_data_value;
 	cnt = arg->data_cnt;
+	loops = arg->loops;
 	list1 = arg->list1;
 	list2 = arg->list2;
 
 	/*
 	 * allocate memory for the data records
 	 */
 	Items = (DataRecord *) PR_CALLOC(sizeof(DataRecord) * cnt);
 	PR_ASSERT(Items != NULL);
@@ -240,16 +249,32 @@ static void stackop(void *thread_arg)
 	 */
 	while (cnt-- > 0) {
 		Items[index].data = val++;
 		PR_StackPush(list1, &Items[index].link);
 		index++;
 	}
 
 	/*
+	 * 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;
 	while (cnt-- > 0) {
 		node = PR_StackPop(list1);
 		if (node == NULL) {
 			PR_fprintf(errhandle, "Error - PR_StackPop returned NULL\n");
 			PR_ASSERT(node != NULL);