Bug 86396: Update NSPR to NSPR_4_8_BETA2.
authorWan-Teh Chang <wtc@google.com>
Tue, 12 May 2009 14:18:38 -0700
changeset 28256 c77fa4f8082532ad9135b70d7ee5a855ec132480
parent 28255 f4d5b61bb7a7728dd2bb0c5cb9b06ca622a663a5
child 28257 9afc23efcbba83d9fec156ec5ca10d8927d098ff
push id6973
push userwtc@google.com
push dateTue, 12 May 2009 21:18:54 +0000
treeherdermozilla-central@c77fa4f80825 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs86396, 492117, 492170, 492303, 492305
milestone1.9.2a1pre
Bug 86396: Update NSPR to NSPR_4_8_BETA2. Also fix bug 492117, bug 492170, bug 492303, bug 492305.
nsprpub/config/nsinstall.c
nsprpub/config/prdepend.h
nsprpub/pr/include/md/_pth.h
nsprpub/pr/include/prinit.h
nsprpub/pr/src/io/prlog.c
nsprpub/pr/src/md/unix/unix.c
nsprpub/pr/src/pthreads/ptio.c
nsprpub/pr/tests/Makefile.in
nsprpub/pr/tests/logfile.c
nsprpub/pr/tests/nst_wince.h
nsprpub/pr/tests/parsetm.c
nsprpub/pr/tests/runtests.pl
nsprpub/pr/tests/runtests.sh
--- a/nsprpub/config/nsinstall.c
+++ b/nsprpub/config/nsinstall.c
@@ -363,51 +363,35 @@ main(int argc, char **argv)
 		if (wc < 0)
 		    fail("cannot write to %s", toname);
 	    }
 	    if (cc < 0)
 		fail("cannot read from %s", name);
 
 	    if (ftruncate(tofd, sb.st_size) < 0)
 		fail("cannot truncate %s", toname);
-	    /*
-	    ** On OpenVMS we can't chmod() until the file is closed, and we
-	    ** have to utime() last since fchown/chmod alter the timestamps.
-	    */
-#ifndef VMS
 	    if (dotimes) {
 		utb.actime = sb.st_atime;
 		utb.modtime = sb.st_mtime;
 		if (utime(toname, &utb) < 0)
 		    fail("cannot set times of %s", toname);
 	    }
 #ifdef HAVE_FCHMOD
 	    if (fchmod(tofd, mode) < 0)
 #else
 	    if (chmod(toname, mode) < 0)
 #endif
 		fail("cannot change mode of %s", toname);
-#endif
 	    if ((owner || group) && fchown(tofd, uid, gid) < 0)
 		fail("cannot change owner of %s", toname);
 
 	    /* Must check for delayed (NFS) write errors on close. */
 	    if (close(tofd) < 0)
 		fail("cannot write to %s", toname);
 	    close(fromfd);
-#ifdef VMS
-	    if (chmod(toname, mode) < 0)
-		fail("cannot change mode of %s", toname);
-	    if (dotimes) {
-		utb.actime = sb.st_atime;
-		utb.modtime = sb.st_mtime;
-		if (utime(toname, &utb) < 0)
-		    fail("cannot set times of %s", toname);
-	    }
-#endif
 	}
 
 	free(toname);
     }
 
     free(cwd);
     free(todir);
     return 0;
--- a/nsprpub/config/prdepend.h
+++ b/nsprpub/config/prdepend.h
@@ -37,8 +37,9 @@
 
 /*
  * 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/pr/include/md/_pth.h
+++ b/nsprpub/pr/include/md/_pth.h
@@ -93,21 +93,17 @@
 #define _PT_PTHREAD_MUTEXATTR_INIT        pthread_mutexattr_init
 #define _PT_PTHREAD_MUTEXATTR_DESTROY     pthread_mutexattr_destroy
 #define _PT_PTHREAD_MUTEX_INIT(m, a)      pthread_mutex_init(&(m), &(a))
 #if defined(FREEBSD)
 #define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    pt_pthread_mutex_is_locked(&(m))
 #else
 #define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    (EBUSY == pthread_mutex_trylock(&(m)))
 #endif
-#if defined(DARWIN)
-#define _PT_PTHREAD_CONDATTR_INIT(x)      0
-#else
 #define _PT_PTHREAD_CONDATTR_INIT         pthread_condattr_init
-#endif
 #define _PT_PTHREAD_CONDATTR_DESTROY      pthread_condattr_destroy
 #define _PT_PTHREAD_COND_INIT(m, a)       pthread_cond_init(&(m), &(a))
 #endif
 
 /* The pthreads standard does not specify an invalid value for the
  * pthread_t handle.  (0 is usually an invalid pthread identifier
  * but there are exceptions, for example, DG/UX.)  These macros
  * define a way to set the handle to or compare the handle with an
--- a/nsprpub/pr/include/prinit.h
+++ b/nsprpub/pr/include/prinit.h
@@ -58,17 +58,17 @@ 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.8 Beta 1"
+#define PR_VERSION  "4.8 Beta 2"
 #define PR_VMAJOR   4
 #define PR_VMINOR   8
 #define PR_VPATCH   0
 #define PR_BETA     PR_TRUE
 
 /*
 ** PRVersionCheck
 **
--- a/nsprpub/pr/src/io/prlog.c
+++ b/nsprpub/pr/src/io/prlog.c
@@ -225,17 +225,17 @@ void _PR_InitLog(void)
             ** == 1, then level defaults to 1 (module enabled).
             */
             if (strcasecmp(module, "sync") == 0) {
                 isSync = PR_TRUE;
             } else if (strcasecmp(module, "bufsize") == 0) {
                 if (level >= LINE_BUF_SIZE) {
                     bufSize = level;
                 }
-            } else if (strcasecmp(module, "__timestamp") == 0) {
+            } else if (strcasecmp(module, "timestamp") == 0) {
                 outputTimeStamp = PR_TRUE;
             } else {
                 PRLogModuleInfo *lm = logModules;
                 PRBool skip_modcheck =
                     (0 == strcasecmp (module, "all")) ? PR_TRUE : PR_FALSE;
 
                 while (lm != NULL) {
                     if (skip_modcheck) lm -> level = (PRLogModuleLevel)level;
@@ -448,19 +448,22 @@ PR_IMPLEMENT(void) PR_LogPrint(const cha
 
     if (!_pr_initialized) _PR_ImplicitInitialization();
 
     if (!logFile) {
         return;
     }
 
     if (outputTimeStamp) {
-        PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &now);
-        nb_tid = PR_FormatTimeUSEnglish(line, sizeof(line)-1,
-                                        "%Y-%m-%d %H:%M:%S - ", &now);
+        PR_ExplodeTime(PR_Now(), PR_GMTParameters, &now);
+        nb_tid = PR_snprintf(line, sizeof(line)-1,
+                             "%04d-%02d-%02d %02d:%02d:%02d.%06d UTC - ",
+                             now.tm_year, now.tm_month, now.tm_mday,
+                             now.tm_hour, now.tm_min, now.tm_sec,
+                             now.tm_usec);
     }
 
     me = PR_GetCurrentThread();
     nb_tid += PR_snprintf(line+nb_tid, sizeof(line)-nb_tid-1, "%ld[%p]: ",
 #if defined(_PR_BTHREADS)
                           me, me);
 #else
                           me ? me->id : 0L, me);
--- a/nsprpub/pr/src/md/unix/unix.c
+++ b/nsprpub/pr/src/md/unix/unix.c
@@ -2644,18 +2644,24 @@ PRInt32 _MD_getopenfileinfo64(const PRFi
     PRInt32 rv = _md_iovector._fstat64(fd->secret->md.osfd, &sb);
     if (rv < 0)
         _PR_MD_MAP_FSTAT_ERROR(_MD_ERRNO());
     else if (NULL != info)
         rv = _MD_convert_stat64_to_fileinfo64(&sb, info);
     return rv;
 }
 
+/*
+ * _md_iovector._open64 must be initialized to 'open' so that _PR_InitLog can
+ * open the log file during NSPR initialization, before _md_iovector is
+ * initialized by _PR_MD_FINAL_INIT.  This means the log file cannot be a
+ * large file on some platforms.
+ */
 #ifdef SYMBIAN
-struct _MD_IOVector _md_iovector;
+struct _MD_IOVector _md_iovector; /* Will crash if NSPR_LOG_FILE is set. */
 #else
 struct _MD_IOVector _md_iovector = { open };
 #endif
 
 /*
 ** These implementations are to emulate large file routines on systems that
 ** don't have them. Their goal is to check in case overflow occurs. Otherwise
 ** they will just operate as normal using 32-bit file routines.
--- a/nsprpub/pr/src/pthreads/ptio.c
+++ b/nsprpub/pr/src/pthreads/ptio.c
@@ -1012,17 +1012,17 @@ static PRBool pt_hpux_sendfile_cont(pt_C
         op->result.code = -1;
     } else {
         return PR_FALSE;
     }
     if (count != -1 && count < op->nbytes_to_send) {
         if (count < hdtrl[0].iov_len) {
 			/* header not sent */
 
-            hdtrl[0].iov_base = ((char *) hdtrl[0].iov_len) + count;
+            hdtrl[0].iov_base = ((char *) hdtrl[0].iov_base) + count;
             hdtrl[0].iov_len -= count;
 
         } else if (count < (hdtrl[0].iov_len + op->arg3.file_spec.nbytes)) {
 			/* header sent, file not sent */
             PRUint32 file_nbytes_sent = count - hdtrl[0].iov_len;
 
             hdtrl[0].iov_base = NULL;
             hdtrl[0].iov_len = 0;
--- a/nsprpub/pr/tests/Makefile.in
+++ b/nsprpub/pr/tests/Makefile.in
@@ -99,16 +99,17 @@ CSRCS =             \
 	joinuk.c        \
 	joinuu.c        \
 	layer.c		    \
 	lazyinit.c		\
 	libfilename.c	\
 	lltest.c        \
 	lock.c          \
 	lockfile.c      \
+	logfile.c       \
 	logger.c		\
 	makedir.c		\
 	mbcs.c			\
 	multiacc.c		\
 	multiwait.c		\
 	many_cv.c		\
 	nameshm1.c      \
 	nbconn.c		\
new file mode 100644
--- /dev/null
+++ b/nsprpub/pr/tests/logfile.c
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Netscape Portable Runtime (NSPR).
+ *
+ * The Initial Developer of the Original Code is
+ * Google Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ * A regression test for bug 491441.  NSPR should not crash on startup in
+ * PR_SetLogFile when the NSPR_LOG_MODULES and NSPR_LOG_FILE environment
+ * variables are set.
+ *
+ * This test could be extended to be a full-blown test for NSPR_LOG_FILE.
+ */
+
+#include "prinit.h"
+#include "prlog.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main()
+{
+    PRLogModuleInfo *test_lm;
+
+    if (putenv("NSPR_LOG_MODULES=all:5") != 0) {
+        fprintf(stderr, "putenv failed\n");
+        exit(1);
+    }
+    if (putenv("NSPR_LOG_FILE=logfile.log") != 0) {
+        fprintf(stderr, "putenv failed\n");
+        exit(1);
+    }
+
+    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
+    test_lm = PR_NewLogModule("test");
+    PR_LOG(test_lm, PR_LOG_MIN, ("logfile: test log message"));
+    PR_Cleanup();
+    return 0;
+}
--- a/nsprpub/pr/tests/nst_wince.h
+++ b/nsprpub/pr/tests/nst_wince.h
@@ -57,19 +57,19 @@
 #undef perror
 #endif
 #define perror(x)
 
 
 /***********
  * Do nothing DllMain -- needed to create a functional DLL
  ***********/
-BOOL WINAPI DllMain( HINSTANCE hDllHandle, 
-                     DWORD     nReason, 
-                     LPVOID    lpvReserved )
+BOOL WINAPI DllMain( HANDLE hDllHandle,
+                     DWORD  nReason,
+                     LPVOID lpvReserved )
 {
   BOOLEAN bSuccess = TRUE;
 
   switch ( nReason )
   {
     case DLL_PROCESS_ATTACH:
       /* Do nothing yet  */
       break;
--- a/nsprpub/pr/tests/parsetm.c
+++ b/nsprpub/pr/tests/parsetm.c
@@ -89,17 +89,17 @@ static void PrintExplodedTime(const PREx
 int main(int argc, char **argv)
 {
     PRTime ct;
     PRExplodedTime et;
     PRStatus rv;
     char *sp1 = "Sat, 1 Jan 3001 00:00:00";  /* no time zone */
     char *sp2 = "Fri, 31 Dec 3000 23:59:60";  /* no time zone, not normalized */
 
-#if _MSC_VER >= 1400
+#if _MSC_VER >= 1400 && !defined(WINCE)
     /* Run this test in the US Pacific Time timezone. */
     _putenv_s("TZ", "PST8PDT");
     _tzset();
 #endif
 
     rv = PR_ParseTimeString(sp1, PR_FALSE, &ct);
     printf("rv = %d\n", rv);
     PR_ExplodeTime(ct, PR_GMTParameters, &et);
--- a/nsprpub/pr/tests/runtests.pl
+++ b/nsprpub/pr/tests/runtests.pl
@@ -314,16 +314,17 @@ sub win_test_prog {
 "joinuk",
 "joinuu",
 "layer",
 "lazyinit",
 "libfilename",
 "lltest",
 "lock",
 "lockfile",
+"logfile",
 "logger",
 "many_cv",
 "multiwait",
 "nameshm1",
 "nblayer",
 "nonblock",
 "ntioto",
 "ntoh",
--- a/nsprpub/pr/tests/runtests.sh
+++ b/nsprpub/pr/tests/runtests.sh
@@ -142,16 +142,17 @@ joinku
 joinuk
 joinuu
 layer
 lazyinit
 libfilename
 lltest
 lock
 lockfile
+logfile
 logger
 many_cv
 multiwait
 nameshm1
 nblayer
 nonblock
 ntioto
 ntoh