Bug 891551: Update NSPR to NSPR_4_10_6_BETA1, which also includes fixes
authorWan-Teh Chang <wtc@google.com>
Fri, 23 May 2014 10:51:29 -0700
changeset 184722 fbab35dfe7e382ea0c2149161a548a3770fcfc33
parent 184721 7809455a72a707172209bbc1eec3abe67149c7d6
child 184723 894ad4e244ece72d5930049fb765a83e81328ca1
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs891551, 1003946, 1009270, 1011861
milestone32.0a1
Bug 891551: Update NSPR to NSPR_4_10_6_BETA1, which also includes fixes for bug 1003946, bug 1009270, and bug 1011861.
nsprpub/TAG-INFO
nsprpub/config/nsinstall.c
nsprpub/config/prdepend.h
nsprpub/configure
nsprpub/configure.in
nsprpub/pr/include/md/_linux.h
nsprpub/pr/include/prinit.h
nsprpub/pr/include/prio.h
nsprpub/pr/src/io/prmapopt.c
nsprpub/pr/src/misc/prsystem.c
nsprpub/pr/src/pthreads/ptio.c
nsprpub/pr/tests/sockopt.c
nsprpub/pr/tests/vercheck.c
--- a/nsprpub/TAG-INFO
+++ b/nsprpub/TAG-INFO
@@ -1,1 +1,1 @@
-NSPR_4_10_5_RTM
+NSPR_4_10_6_BETA1
--- a/nsprpub/config/nsinstall.c
+++ b/nsprpub/config/nsinstall.c
@@ -203,17 +203,16 @@ main(int argc, char **argv)
     }
     xchdir(todir);
 #ifdef GETCWD_CAN_MALLOC
     todir = getcwd(0, PATH_MAX);
 #else
     todir = malloc(PATH_MAX + 1);
     todir = getcwd(todir, PATH_MAX);
 #endif
-    tdlen = strlen(todir);
     xchdir(cwd);
     tdlen = strlen(todir);
 
     uid = owner ? touid(owner) : -1;
     gid = group ? togid(group) : -1;
 
     while (--argc > 0) {
 	name = *argv++;
--- a/nsprpub/config/prdepend.h
+++ b/nsprpub/config/prdepend.h
@@ -5,9 +5,8 @@
 
 /*
  * A dummy header file that is a dependency for all the object files.
  * Used to force a full recompilation of NSPR in Mozilla's Tinderbox
  * depend builds.  See comments in rules.mk.
  */
 
 #error "Do not include this header file."
-
--- a/nsprpub/configure
+++ b/nsprpub/configure
@@ -2482,17 +2482,17 @@ case $target_os in *\ *) target_os=`echo
 # will get canonicalized.
 test -n "$target_alias" &&
   test "$program_prefix$program_suffix$program_transform_name" = \
     NONENONEs,x,x, &&
   program_prefix=${target_alias}-
 
 MOD_MAJOR_VERSION=4
 MOD_MINOR_VERSION=10
-MOD_PATCH_VERSION=5
+MOD_PATCH_VERSION=6
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
 USE_USER_PTHREADS=
 USE_NSPR_THREADS=
 USE_N32=
 USE_X32=
 USE_64=
--- a/nsprpub/configure.in
+++ b/nsprpub/configure.in
@@ -11,17 +11,17 @@ AC_CONFIG_SRCDIR([pr/include/nspr.h])
 AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
 AC_CANONICAL_TARGET
 
 dnl ========================================================
 dnl = Defaults
 dnl ========================================================
 MOD_MAJOR_VERSION=4
 MOD_MINOR_VERSION=10
-MOD_PATCH_VERSION=5
+MOD_PATCH_VERSION=6
 NSPR_MODNAME=nspr20
 _HAVE_PTHREADS=
 USE_PTHREADS=
 USE_USER_PTHREADS=
 USE_NSPR_THREADS=
 USE_N32=
 USE_X32=
 USE_64=
--- a/nsprpub/pr/include/md/_linux.h
+++ b/nsprpub/pr/include/md/_linux.h
@@ -75,17 +75,17 @@
  * Elf linux supports dl* functions
  */
 #define HAVE_DLL
 #define USE_DLFCN
 #if defined(ANDROID)
 #define NO_DLOPEN_NULL
 #endif
 
-#ifdef __FreeBSD_kernel__
+#if defined(__FreeBSD_kernel__) || defined(__GNU__)
 #define _PR_HAVE_SOCKADDR_LEN
 #endif
 
 #if defined(__i386__)
 #define _PR_HAVE_ATOMIC_OPS
 #define _MD_INIT_ATOMIC()
 extern PRInt32 _PR_x86_AtomicIncrement(PRInt32 *val);
 #define _MD_ATOMIC_INCREMENT          _PR_x86_AtomicIncrement
--- a/nsprpub/pr/include/prinit.h
+++ b/nsprpub/pr/include/prinit.h
@@ -26,21 +26,21 @@ PR_BEGIN_EXTERN_C
 /*
 ** NSPR's version is used to determine the likelihood that the version you
 ** used to build your component is anywhere close to being compatible with
 ** what is in the underlying library.
 **
 ** The format of the version string is
 **     "<major version>.<minor version>[.<patch level>] [<Beta>]"
 */
-#define PR_VERSION  "4.10.5"
+#define PR_VERSION  "4.10.6 Beta"
 #define PR_VMAJOR   4
 #define PR_VMINOR   10
-#define PR_VPATCH   5
-#define PR_BETA     PR_FALSE
+#define PR_VPATCH   6
+#define PR_BETA     PR_TRUE
 
 /*
 ** PRVersionCheck
 **
 ** The basic signature of the function that is called to provide version
 ** checking. The result will be a boolean that indicates the likelihood
 ** that the underling library will perform as the caller expects.
 **
--- a/nsprpub/pr/include/prio.h
+++ b/nsprpub/pr/include/prio.h
@@ -206,16 +206,18 @@ typedef enum PRSockOption
     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_Reuseport,       /* allow local address & port reuse on
+                                 * platforms that support it */
     PR_SockOpt_Last
 } PRSockOption;
 
 typedef struct PRLinger {
 	PRBool polarity;		    /* Polarity of the option's setting */
 	PRIntervalTime linger;	    /* Time to linger before closing */
 } PRLinger;
 
@@ -229,16 +231,18 @@ typedef struct PRSocketOptionData
     PRSockOption option;
     union
     {
         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 reuse_port;          /* Allow local address & port reuse on
+                                     * platforms that support it */
         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 */
--- a/nsprpub/pr/src/io/prmapopt.c
+++ b/nsprpub/pr/src/io/prmapopt.c
@@ -80,16 +80,17 @@ PRStatus PR_CALLBACK _PR_SocketGetSocket
                 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:
+            case PR_SockOpt_Reuseport:
             {
 #ifdef WIN32 /* Winsock */
                 BOOL value;
 #else
                 PRIntn value;
 #endif
                 length = sizeof(value);
                 rv = _PR_MD_GETSOCKOPT(
@@ -231,16 +232,17 @@ PRStatus PR_CALLBACK _PR_SocketSetSocket
                 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:
+            case PR_SockOpt_Reuseport:
             {
 #ifdef WIN32 /* Winsock */
                 BOOL value;
 #else
                 PRIntn value;
 #endif
                 value = (data->value.reuse_addr) ? 1 : 0;
                 rv = _PR_MD_SETSOCKOPT(
@@ -407,36 +409,40 @@ PRStatus PR_CALLBACK _PR_SocketSetSocket
 #ifndef TCP_NODELAY                     /* don't delay to coalesce data     */
 #define TCP_NODELAY         _PR_NO_SUCH_SOCKOPT
 #endif
 
 #ifndef TCP_MAXSEG                      /* maxumum segment size for tcp     */
 #define TCP_MAXSEG          _PR_NO_SUCH_SOCKOPT
 #endif
 
-#ifndef SO_BROADCAST                 /* enable broadcast on udp sockets */
+#ifndef SO_BROADCAST                    /* enable broadcast on UDP sockets  */
 #define SO_BROADCAST        _PR_NO_SUCH_SOCKOPT
 #endif
 
+#ifndef SO_REUSEPORT                    /* allow local address & port reuse */
+#define SO_REUSEPORT        _PR_NO_SUCH_SOCKOPT
+#endif
+
 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, SO_BROADCAST
+        TCP_NODELAY, TCP_MAXSEG, SO_BROADCAST, SO_REUSEPORT
     };
     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, SOL_SOCKET
+        IPPROTO_TCP, IPPROTO_TCP, SOL_SOCKET, SOL_SOCKET
     };
 
     if ((optname < PR_SockOpt_Linger)
     || (optname >= PR_SockOpt_Last))
     {
         PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
         return PR_FAILURE;
     }
--- a/nsprpub/pr/src/misc/prsystem.c
+++ b/nsprpub/pr/src/misc/prsystem.c
@@ -28,16 +28,17 @@
 #define _PR_HAVE_SYSCTL
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #endif
 
 #if defined(DARWIN)
 #include <mach/mach_init.h>
 #include <mach/mach_host.h>
+#include <mach/mach_port.h>
 #endif
 
 #if defined(HPUX)
 #include <sys/mpctl.h>
 #include <sys/pstat.h>
 #endif
 
 #if defined(XP_UNIX)
@@ -292,23 +293,25 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMem
 
     struct pst_static info;
     int result = pstat_getstatic(&info, sizeof(info), 1, 0);
     if (result == 1)
         bytes = (PRUint64) info.physical_memory * info.page_size;
 
 #elif defined(DARWIN)
 
+    mach_port_t mach_host = mach_host_self();
     struct host_basic_info hInfo;
     mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT;
 
-    int result = host_info(mach_host_self(),
+    int result = host_info(mach_host,
                            HOST_BASIC_INFO,
                            (host_info_t) &hInfo,
                            &count);
+    mach_port_deallocate(mach_task_self(), mach_host);
     if (result == KERN_SUCCESS)
         bytes = hInfo.max_mem;
 
 #elif defined(WIN32)
 
     MEMORYSTATUSEX memStat;
     memStat.dwLength = sizeof(memStat);
     if (GlobalMemoryStatusEx(&memStat))
--- a/nsprpub/pr/src/pthreads/ptio.c
+++ b/nsprpub/pr/src/pthreads/ptio.c
@@ -2849,16 +2849,17 @@ static PRStatus pt_GetSocketOption(PRFil
                 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:
+            case PR_SockOpt_Reuseport:
             {
                 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;
@@ -2968,16 +2969,17 @@ static PRStatus pt_SetSocketOption(PRFil
                 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:
+            case PR_SockOpt_Reuseport:
             {
                 PRIntn value = (data->value.reuse_addr) ? 1 : 0;
                 rv = setsockopt(
                     fd->secret->md.osfd, level, name,
                     (char*)&value, sizeof(PRIntn));
 #ifdef LINUX
                 /* for pt_LinuxSendFile */
                 if (name == TCP_NODELAY && rv == 0) {
--- a/nsprpub/pr/tests/sockopt.c
+++ b/nsprpub/pr/tests/sockopt.c
@@ -6,16 +6,20 @@
 #include "nspr.h"
 #include "prio.h"
 #include "prinit.h"
 #include "prprf.h"
 #include "obsolete/probslet.h"
 
 #include "plerror.h"
 
+#ifdef XP_UNIX
+#include <sys/socket.h>  /* SO_REUSEPORT */
+#endif
+
 static PRFileDesc *err = NULL;
 static PRBool failed = PR_FALSE;
 
 static void Failed(const char *msg1, const char *msg2)
 {
     if (NULL != msg1) PR_fprintf(err, "%s ", msg1);
     PL_FPrintError(err, msg2);
     failed = PR_TRUE;
@@ -49,16 +53,17 @@ int main(int argc, char **argv)
         "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_Reuseport",       /* allow local address & port reuse */
         "PR_SockOpt_Last"
     };
 
     err = PR_GetSpecialFD(PR_StandardError);
     PR_STDIO_INIT();
 
     if (NULL == udp) Failed("PR_NewUDPSocket()", NULL);
     else if (NULL == tcp) Failed("PR_NewTCPSocket()", NULL);
@@ -125,16 +130,21 @@ int main(int argc, char **argv)
                     break;    
 #endif
 #ifndef SYMBIAN
                 case PR_SockOpt_Broadcast:
                     fd = udp; 
                     data.value.broadcast = PR_TRUE;         
                     break;    
 #endif
+#ifdef SO_REUSEPORT
+                case PR_SockOpt_Reuseport:
+                    data.value.reuse_port = PR_TRUE;
+                    break;
+#endif
                 default: continue;
             }
 
 			/*
 			 * TCP_MAXSEG can only be read, not set
 			 */
             if (option != PR_SockOpt_MaxSegment) {
 #ifdef WIN32
--- a/nsprpub/pr/tests/vercheck.c
+++ b/nsprpub/pr/tests/vercheck.c
@@ -15,51 +15,52 @@
  */
 
 #include "prinit.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 
 /*
- * This release (4.10.5) is backward compatible with the
+ * This release (4.10.6) is backward compatible with the
  * 4.0.x, 4.1.x, 4.2.x, 4.3.x, 4.4.x, 4.5.x, 4.6.x, 4.7.x,
- * 4.8.x, 4.9.x, 4.10, 4.10.1, 4.10.2, 4.10.3, and 4.10.4
- * releases.
+ * 4.8.x, 4.9.x, 4.10, 4.10.1, 4.10.2, 4.10.3, 4.10.4, and
+ * 4.10.5 releases.
  * It, of course, is compatible with itself.
  */
 static char *compatible_version[] = {
     "4.0", "4.0.1", "4.1", "4.1.1", "4.1.2", "4.1.3",
     "4.2", "4.2.1", "4.2.2", "4.3", "4.4", "4.4.1",
     "4.5", "4.5.1",
     "4.6", "4.6.1", "4.6.2", "4.6.3", "4.6.4", "4.6.5",
     "4.6.6", "4.6.7", "4.6.8",
     "4.7", "4.7.1", "4.7.2", "4.7.3", "4.7.4", "4.7.5",
     "4.7.6",
     "4.8", "4.8.1", "4.8.2", "4.8.3", "4.8.4", "4.8.5",
     "4.8.6", "4.8.7", "4.8.8", "4.8.9",
     "4.9", "4.9.1", "4.9.2", "4.9.3", "4.9.4", "4.9.5",
     "4.9.6",
     "4.10", "4.10.1", "4.10.2", "4.10.3", "4.10.4",
+    "4.10.5",
     PR_VERSION
 };
 
 /*
  * This release is not backward compatible with the old
  * NSPR 2.1 and 3.x releases.
  *
  * Any release is incompatible with future releases and
  * patches.
  */
 static char *incompatible_version[] = {
     "2.1 19980529",
     "3.0", "3.0.1",
     "3.1", "3.1.1", "3.1.2", "3.1.3",
     "3.5", "3.5.1",
-    "4.10.6",
+    "4.10.7",
     "4.11", "4.11.1",
     "10.0", "11.1", "12.14.20"
 };
 
 int main(int argc, char **argv)
 {
     int idx;
     int num_compatible = sizeof(compatible_version) / sizeof(char *);