OLD | NEW |
1 /* | 1 /* |
2 * NSS utility functions | 2 * NSS utility functions |
3 * | 3 * |
4 * This Source Code Form is subject to the terms of the Mozilla Public | 4 * This Source Code Form is subject to the terms of the Mozilla Public |
5 * License, v. 2.0. If a copy of the MPL was not distributed with this | 5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
7 | 7 |
8 #include "prtypes.h" | 8 #include "prtypes.h" |
9 #include "prinit.h" | 9 #include "prinit.h" |
10 #include "seccomon.h" | 10 #include "seccomon.h" |
11 #include "secerr.h" | 11 #include "secerr.h" |
12 #include "ssl.h" | 12 #include "ssl.h" |
13 #include "sslimpl.h" | 13 #include "sslimpl.h" |
| 14 #include "sslproto.h" |
14 | 15 |
15 static int ssl_inited = 0; | 16 static int ssl_isInited = 0; |
| 17 static PRCallOnceType ssl_init = { 0 }; |
| 18 |
| 19 PRStatus |
| 20 ssl_InitCallOnce(void *arg) |
| 21 { |
| 22 int *error = (int *)arg; |
| 23 SECStatus rv; |
| 24 |
| 25 rv = ssl_InitializePRErrorTable(); |
| 26 if (rv != SECSuccess) { |
| 27 *error = SEC_ERROR_NO_MEMORY; |
| 28 return PR_FAILURE; |
| 29 } |
| 30 #ifdef DEBUG |
| 31 ssl3_CheckCipherSuiteOrderConsistency(); |
| 32 #endif |
| 33 |
| 34 rv = ssl3_ApplyNSSPolicy(); |
| 35 if (rv != SECSuccess) { |
| 36 *error = PORT_GetError(); |
| 37 return PR_FAILURE; |
| 38 } |
| 39 return PR_SUCCESS; |
| 40 } |
16 | 41 |
17 SECStatus | 42 SECStatus |
18 ssl_Init(void) | 43 ssl_Init(void) |
19 { | 44 { |
20 if (!ssl_inited) { | 45 PRStatus nrv; |
21 » if (ssl_InitializePRErrorTable() != SECSuccess) { | |
22 » PORT_SetError(SEC_ERROR_NO_MEMORY); | |
23 » return (SECFailure); | |
24 » } | |
25 | 46 |
26 #ifdef DEBUG | 47 /* short circuit test if we are already inited */ |
27 ssl3_CheckCipherSuiteOrderConsistency(); | 48 if (!ssl_isInited) { |
28 #endif | 49 int error; |
29 | 50 /* only do this once at init time, block all others until we are done */ |
30 » ssl_inited = 1; | 51 nrv = PR_CallOnceWithArg(&ssl_init, ssl_InitCallOnce, &error); |
| 52 if (nrv != PR_SUCCESS) { |
| 53 PORT_SetError(error); |
| 54 return SECFailure; |
| 55 } |
| 56 ssl_isInited = 1; |
31 } | 57 } |
32 return SECSuccess; | 58 return SECSuccess; |
33 } | 59 } |
OLD | NEW |