]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_crypto: Fix ceph::crypto::init mutex for NSS.
authorTommi Virtanen <tommi.virtanen@dreamhost.com>
Thu, 5 May 2011 21:07:02 +0000 (14:07 -0700)
committerTommi Virtanen <tommi.virtanen@dreamhost.com>
Thu, 5 May 2011 21:07:02 +0000 (14:07 -0700)
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 <tommi.virtanen@dreamhost.com>
src/common/ceph_crypto.cc

index e38f4e5b55e0ca5388cebd7c1a290a8458be9312..b6520d7087426cc5235396c8038db818eb177b15 100644 (file)
@@ -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);