]> git.saurik.com Git - apple/security.git/blobdiff - libsecurity_cdsa_client/lib/macclient.cpp
Security-55471.14.8.tar.gz
[apple/security.git] / libsecurity_cdsa_client / lib / macclient.cpp
index 38c8b6a7f4dc24c4bf44aaa940342134f4a7a00a..c821cc99abc4c8f339e4111284c4ddeebc25b739 100644 (file)
@@ -29,14 +29,18 @@ using namespace CssmClient;
 //
 void MacContext::activate()
 {
-       if (!mActive) 
-       {
-               check(CSSM_CSP_CreateMacContext(attachment()->handle(), mAlgorithm,
-                         mKey, &mHandle));
-               mActive = true;
-               if (cred())
-                       cred(cred());           // install explicitly
-       }
+    {
+        StLock<Mutex> _(mActivateMutex);
+        if (!mActive) 
+        {
+            check(CSSM_CSP_CreateMacContext(attachment()->handle(), mAlgorithm,
+                  mKey, &mHandle));
+            mActive = true;
+        }
+    }
+
+    if (cred())
+        cred(cred());          // install explicitly
 }