From: Tommi Virtanen Date: Thu, 5 May 2011 21:07:02 +0000 (-0700) Subject: ceph_crypto: Fix ceph::crypto::init mutex for NSS. X-Git-Tag: v0.28~78 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=79b1a101492347101fa6562402f6ddc6a0ac2124;p=ceph.git ceph_crypto: Fix ceph::crypto::init mutex for NSS. Even after ceph::crypto::shutdown, the library looked already initialized; this broke the ForkDeathTest.MD5 in "make check", and NSS-using daemons. See 921d4b3d8b79485a6786f8ca75b2a96ea377da84 for more. Signed-off-by: Tommi Virtanen --- diff --git a/src/common/ceph_crypto.cc b/src/common/ceph_crypto.cc index e38f4e5b55e0c..b6520d7087426 100644 --- a/src/common/ceph_crypto.cc +++ b/src/common/ceph_crypto.cc @@ -24,9 +24,10 @@ ceph::crypto::HMACSHA1::~HMACSHA1() #elif USE_NSS +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; +static bool crypto_init = false; + void ceph::crypto::init() { - static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; - static bool crypto_init = false; pthread_mutex_lock(&lock); if (crypto_init) { pthread_mutex_unlock(&lock); @@ -41,6 +42,10 @@ void ceph::crypto::init() { } void ceph::crypto::shutdown() { + pthread_mutex_lock(&lock); + assert(crypto_init); + crypto_init = false; + pthread_mutex_unlock(&lock); SECStatus s; s = NSS_Shutdown(); assert(s == SECSuccess);