From 3a1097367993bd96d99e33d7bcb9b5dd40bc1ecc Mon Sep 17 00:00:00 2001 From: "nelsonb%netscape.com" Date: Sat, 10 Sep 2005 01:18:40 +0000 Subject: [PATCH] Fix regression introduced in last checkin. If the caller disables the use of locks while locks are in use, don't forget to unlock the locks already locked on the stack. bug 305147. r=julien.pierre git-svn-id: svn://10.0.0.236/trunk@179937 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/security/nss/lib/ssl/sslsock.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mozilla/security/nss/lib/ssl/sslsock.c b/mozilla/security/nss/lib/ssl/sslsock.c index aa6e5b6b2ef..72930b3647f 100644 --- a/mozilla/security/nss/lib/ssl/sslsock.c +++ b/mozilla/security/nss/lib/ssl/sslsock.c @@ -40,7 +40,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/* $Id: sslsock.c,v 1.39 2005-09-09 03:02:16 nelsonb%netscape.com Exp $ */ +/* $Id: sslsock.c,v 1.40 2005-09-10 01:18:40 nelsonb%netscape.com Exp $ */ #include "seccomon.h" #include "cert.h" #include "keyhi.h" @@ -491,12 +491,14 @@ SSL_OptionSet(PRFileDesc *fd, PRInt32 which, PRBool on) { sslSocket *ss = ssl_FindSocket(fd); SECStatus rv = SECSuccess; + PRBool holdingLocks; if (!ss) { SSL_DBG(("%d: SSL[%d]: bad socket in Enable", SSL_GETPID(), fd)); return SECFailure; } + holdingLocks = (!ss->opt.noLocks); ssl_Get1stHandshakeLock(ss); ssl_GetSSL3HandshakeLock(ss); @@ -619,8 +621,15 @@ SSL_OptionSet(PRFileDesc *fd, PRInt32 which, PRBool on) rv = SECFailure; } - ssl_ReleaseSSL3HandshakeLock(ss); - ssl_Release1stHandshakeLock(ss); + /* We can't use the macros for releasing the locks here, + * because ss->opt.noLocks might have changed just above. + * We must release these locks (monitors) here, if we aquired them above, + * regardless of the current value of ss->opt.noLocks. + */ + if (holdingLocks) { + PZ_ExitMonitor((ss)->ssl3HandshakeLock); + PZ_ExitMonitor((ss)->firstHandshakeLock); + } return rv; }