Fix for bug 353899 . PR_CallOnce and PR_CallOnceWithArg do not set NSPR error code if once->initialized is TRUE and once->status is PR_FAILURE . r=wtc NSPRPUB_PRE_4_2_CLIENT_BRANCH
authorwtc%google.com
Mon, 14 May 2007 20:18:32 +0000
branchNSPRPUB_PRE_4_2_CLIENT_BRANCH
changeset 3839 b0a6e6a0150a4e57130ecd7261cf6225dfe52a38
parent 3838 fdd106c0e79c7f9ea014486c735830b92cf435d7
child 3840 1e5546f7bcae61d75bccb86481051327a24cb27b
push idunknown
push userunknown
push dateunknown
reviewerswtc
bugs353899
Fix for bug 353899 . PR_CallOnce and PR_CallOnceWithArg do not set NSPR error code if once->initialized is TRUE and once->status is PR_FAILURE . r=wtc Modified Files: prerr.h prerr.c prerr.et prerr.properties prinit.c Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
pr/include/prerr.h
pr/src/misc/prerr.c
pr/src/misc/prerr.et
pr/src/misc/prerr.properties
pr/src/misc/prinit.c
--- a/pr/include/prerr.h
+++ b/pr/include/prerr.h
@@ -264,15 +264,18 @@
 #define PR_CONNECT_ABORTED_ERROR                 (-5928L)
 
 /* Host is unreachable */
 #define PR_HOST_UNREACHABLE_ERROR                (-5927L)
 
 /* The library is not loaded */
 #define PR_LIBRARY_NOT_LOADED_ERROR              (-5926L)
 
+/* The one-time function was previously called and failed. Its error code is no longer available */
+#define PR_CALL_ONCE_ERROR                       (-5925L)
+
 /* Placeholder for the end of the list */
-#define PR_MAX_ERROR                             (-5925L)
+#define PR_MAX_ERROR                             (-5924L)
 
 extern void nspr_InitializePRErrorTable(void);
 #define ERROR_TABLE_BASE_nspr (-6000L)
 
 #endif /* prerr_h___ */
--- a/pr/src/misc/prerr.c
+++ b/pr/src/misc/prerr.c
@@ -112,17 +112,18 @@ static const struct PRErrorMessage text[
 	{"PR_ALREADY_INITIATED_ERROR",    "Operation has already been initiated (probably a non-blocking connect)"},
 	{"PR_GROUP_EMPTY_ERROR",    "The wait group is empty"},
 	{"PR_INVALID_STATE_ERROR",    "Object state improper for request"},
 	{"PR_NETWORK_DOWN_ERROR",    "Network is down"},
 	{"PR_SOCKET_SHUTDOWN_ERROR",    "Socket shutdown"},
 	{"PR_CONNECT_ABORTED_ERROR",    "Connection aborted"},
 	{"PR_HOST_UNREACHABLE_ERROR",    "Host is unreachable"},
 	{"PR_LIBRARY_NOT_LOADED_ERROR",    "The library is not loaded"},
+	{"PR_CALL_ONCE_ERROR",    "The one-time function was previously called and failed. Its error code is no longer available"},
 	{"PR_MAX_ERROR",    "Placeholder for the end of the list"},
 	{0, 0}
 };
 
-static const struct PRErrorTable et = { text, "prerr", -6000L, 76 };
+static const struct PRErrorTable et = { text, "prerr", -6000L, 77 };
 
 void nspr_InitializePRErrorTable(void) {
     PR_ErrorInstallTable(&et);
 }
--- a/pr/src/misc/prerr.et
+++ b/pr/src/misc/prerr.et
@@ -128,12 +128,13 @@ ec PR_ALREADY_INITIATED_ERROR,
 "Operation has already been initiated (probably a non-blocking connect)"
 ec PR_GROUP_EMPTY_ERROR,        "The wait group is empty"
 ec PR_INVALID_STATE_ERROR,      "Object state improper for request"
 ec PR_NETWORK_DOWN_ERROR,       "Network is down"
 ec PR_SOCKET_SHUTDOWN_ERROR,    "Socket shutdown"
 ec PR_CONNECT_ABORTED_ERROR,    "Connection aborted"
 ec PR_HOST_UNREACHABLE_ERROR,   "Host is unreachable"
 ec PR_LIBRARY_NOT_LOADED_ERROR, "The library is not loaded"
+ec PR_CALL_ONCE_ERROR, "The one-time function was previously called and failed. Its error code is no longer available"
 
 ec PR_MAX_ERROR,                "Placeholder for the end of the list"
 
 end
--- a/pr/src/misc/prerr.properties
+++ b/pr/src/misc/prerr.properties
@@ -108,9 +108,10 @@ PR_IN_PROGRESS_ERROR=Operation is still 
 PR_ALREADY_INITIATED_ERROR=Operation has already been initiated (probably a non-blocking connect)
 PR_GROUP_EMPTY_ERROR=The wait group is empty
 PR_INVALID_STATE_ERROR=Object state improper for request
 PR_NETWORK_DOWN_ERROR=Network is down
 PR_SOCKET_SHUTDOWN_ERROR=Socket shutdown
 PR_CONNECT_ABORTED_ERROR=Connection aborted
 PR_HOST_UNREACHABLE_ERROR=Host is unreachable
 PR_LIBRARY_NOT_LOADED_ERROR=The library is not loaded
+PR_CALL_ONCE_ERROR=The one-time function was previously called and failed. Its error code is no longer available
 PR_MAX_ERROR=Placeholder for the end of the list
--- a/pr/src/misc/prinit.c
+++ b/pr/src/misc/prinit.c
@@ -819,16 +819,20 @@ PR_IMPLEMENT(PRStatus) PR_CallOnce(
 	    PR_Unlock(mod_init.ml);
 	} else {
 	    PR_Lock(mod_init.ml);
 	    while (!once->initialized) {
 		PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT);
             }
 	    PR_Unlock(mod_init.ml);
 	}
+    } else {
+        if (PR_SUCCESS != once->status) {
+            PR_SetError(PR_CALL_ONCE_ERROR, 0);
+        }
     }
     return once->status;
 }
 
 PR_IMPLEMENT(PRStatus) PR_CallOnceWithArg(
     PRCallOnceType      *once,
     PRCallOnceWithArgFN  func,
     void                *arg)
@@ -844,16 +848,20 @@ PR_IMPLEMENT(PRStatus) PR_CallOnceWithAr
 	    PR_Unlock(mod_init.ml);
 	} else {
 	    PR_Lock(mod_init.ml);
 	    while (!once->initialized) {
 		PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT);
             }
 	    PR_Unlock(mod_init.ml);
 	}
+    } else {
+        if (PR_SUCCESS != once->status) {
+            PR_SetError(PR_CALL_ONCE_ERROR, 0);
+        }
     }
     return once->status;
 }
 
 PRBool _PR_Obsolete(const char *obsolete, const char *preferred)
 {
 #if defined(DEBUG)
 #ifndef XP_MAC