| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Various SSL functions. | 2 * Various SSL functions. |
| 3 * | 3 * |
| 4 * ***** BEGIN LICENSE BLOCK ***** | 4 * ***** BEGIN LICENSE BLOCK ***** |
| 5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 6 * | 6 * |
| 7 * The contents of this file are subject to the Mozilla Public License Version | 7 * The contents of this file are subject to the Mozilla Public License Version |
| 8 * 1.1 (the "License"); you may not use this file except in compliance with | 8 * 1.1 (the "License"); you may not use this file except in compliance with |
| 9 * the License. You may obtain a copy of the License at | 9 * the License. You may obtain a copy of the License at |
| 10 * http://www.mozilla.org/MPL/ | 10 * http://www.mozilla.org/MPL/ |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 if (!ss) { | 381 if (!ss) { |
| 382 SSL_DBG(("%d: SSL[%d]: bad socket in ForceHandshake", | 382 SSL_DBG(("%d: SSL[%d]: bad socket in ForceHandshake", |
| 383 SSL_GETPID(), fd)); | 383 SSL_GETPID(), fd)); |
| 384 return rv; | 384 return rv; |
| 385 } | 385 } |
| 386 | 386 |
| 387 /* Don't waste my time */ | 387 /* Don't waste my time */ |
| 388 if (!ss->opt.useSecurity) | 388 if (!ss->opt.useSecurity) |
| 389 return SECSuccess; | 389 return SECSuccess; |
| 390 | 390 |
| 391 if (!ssl_SocketIsBlocking(ss)) { |
| 392 ssl_GetXmitBufLock(ss); |
| 393 if (ss->pendingBuf.len != 0) { |
| 394 rv = ssl_SendSavedWriteData(ss); |
| 395 if ((rv < 0) && (PORT_GetError() != PR_WOULD_BLOCK_ERROR)) { |
| 396 ssl_ReleaseXmitBufLock(ss); |
| 397 return SECFailure; |
| 398 } |
| 399 } |
| 400 ssl_ReleaseXmitBufLock(ss); |
| 401 } |
| 402 |
| 391 ssl_Get1stHandshakeLock(ss); | 403 ssl_Get1stHandshakeLock(ss); |
| 392 | 404 |
| 393 if (ss->version >= SSL_LIBRARY_VERSION_3_0) { | 405 if (ss->version >= SSL_LIBRARY_VERSION_3_0) { |
| 394 int gatherResult; | 406 int gatherResult; |
| 395 | 407 |
| 396 ssl_GetRecvBufLock(ss); | 408 ssl_GetRecvBufLock(ss); |
| 397 gatherResult = ssl3_GatherCompleteHandshake(ss, 0); | 409 gatherResult = ssl3_GatherCompleteHandshake(ss, 0); |
| 398 ssl_ReleaseRecvBufLock(ss); | 410 ssl_ReleaseRecvBufLock(ss); |
| 399 if (gatherResult > 0) { | 411 if (gatherResult > 0) { |
| 400 rv = SECSuccess; | 412 rv = SECSuccess; |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 } | 1133 } |
| 1122 | 1134 |
| 1123 if (!ssl_SocketIsBlocking(ss) && !ss->opt.fdx) { | 1135 if (!ssl_SocketIsBlocking(ss) && !ss->opt.fdx) { |
| 1124 ssl_GetXmitBufLock(ss); | 1136 ssl_GetXmitBufLock(ss); |
| 1125 if (ss->pendingBuf.len != 0) { | 1137 if (ss->pendingBuf.len != 0) { |
| 1126 rv = ssl_SendSavedWriteData(ss); | 1138 rv = ssl_SendSavedWriteData(ss); |
| 1127 if ((rv < 0) && (PORT_GetError() != PR_WOULD_BLOCK_ERROR)) { | 1139 if ((rv < 0) && (PORT_GetError() != PR_WOULD_BLOCK_ERROR)) { |
| 1128 ssl_ReleaseXmitBufLock(ss); | 1140 ssl_ReleaseXmitBufLock(ss); |
| 1129 return SECFailure; | 1141 return SECFailure; |
| 1130 } | 1142 } |
| 1131 /* XXX short write? */ | |
| 1132 } | 1143 } |
| 1133 ssl_ReleaseXmitBufLock(ss); | 1144 ssl_ReleaseXmitBufLock(ss); |
| 1134 } | 1145 } |
| 1135 | 1146 |
| 1136 rv = 0; | 1147 rv = 0; |
| 1137 /* If any of these is non-zero, the initial handshake is not done. */ | 1148 /* If any of these is non-zero, the initial handshake is not done. */ |
| 1138 if (!ss->firstHsDone) { | 1149 if (!ss->firstHsDone) { |
| 1139 ssl_Get1stHandshakeLock(ss); | 1150 ssl_Get1stHandshakeLock(ss); |
| 1140 if (ss->handshake || ss->nextHandshake || ss->securityHandshake) { | 1151 if (ss->handshake || ss->nextHandshake || ss->securityHandshake) { |
| 1141 rv = ssl_Do1stHandshake(ss); | 1152 rv = ssl_Do1stHandshake(ss); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1523 if (!ss) { | 1534 if (!ss) { |
| 1524 SSL_DBG(("%d: SSL[%d]: bad socket in SNISocketConfigHook", | 1535 SSL_DBG(("%d: SSL[%d]: bad socket in SNISocketConfigHook", |
| 1525 SSL_GETPID(), fd)); | 1536 SSL_GETPID(), fd)); |
| 1526 return SECFailure; | 1537 return SECFailure; |
| 1527 } | 1538 } |
| 1528 | 1539 |
| 1529 ss->sniSocketConfig = func; | 1540 ss->sniSocketConfig = func; |
| 1530 ss->sniSocketConfigArg = arg; | 1541 ss->sniSocketConfigArg = arg; |
| 1531 return SECSuccess; | 1542 return SECSuccess; |
| 1532 } | 1543 } |
| OLD | NEW |