]> git.saurik.com Git - apple/security.git/blobdiff - libsecurity_cdsa_client/lib/cssmclient.cpp
Security-55471.14.8.tar.gz
[apple/security.git] / libsecurity_cdsa_client / lib / cssmclient.cpp
index ec3fb44da7ff99b5e6e3179b95592f54ae28493f..dc091bb52b81887407d92533be995bcb7dbb8fcd 100644 (file)
@@ -30,7 +30,7 @@
 // and thus don't need to be interlocked explicitly.
 //
 #include <security_cdsa_client/cssmclient.h>
 // and thus don't need to be interlocked explicitly.
 //
 #include <security_cdsa_client/cssmclient.h>
-
+#include <syslog.h>
 
 using namespace CssmClient;
 
 
 using namespace CssmClient;
 
@@ -77,8 +77,11 @@ ObjectImpl::ObjectImpl(const Object &mommy) : mParent(mommy.mImpl), mChildCount(
 ObjectImpl::~ObjectImpl()
 try
 {
 ObjectImpl::~ObjectImpl()
 try
 {
-       assert(!mActive);       // subclass must have deactivated us
-       assert(isIdle());
+    if (!isIdle())
+    {
+        int i = mChildCount;
+        syslog(LOG_ALERT, "Object %p still has %d children at delete.\n", this, i);
+    }
                
        // release parent from her obligations (if we still have one)
        if (mParent)
                
        // release parent from her obligations (if we still have one)
        if (mParent)
@@ -193,6 +196,7 @@ CssmImpl::standard()
 void
 CssmImpl::activate()
 {
 void
 CssmImpl::activate()
 {
+    StLock<Mutex> _(mActivateMutex);
        if (!mActive)
        {
                // currently, no choices on PVC mode and key hierarchy
        if (!mActive)
        {
                // currently, no choices on PVC mode and key hierarchy
@@ -213,6 +217,7 @@ CssmImpl::activate()
 void
 CssmImpl::deactivate()
 {
 void
 CssmImpl::deactivate()
 {
+    StLock<Mutex> _(mActivateMutex);
        if (mActive)
        {
                mActive = false;
        if (mActive)
        {
                mActive = false;
@@ -396,16 +401,20 @@ ModuleImpl::appNotifyCallback(RawModuleEvents *handler)
 void
 ModuleImpl::activate()
 {
 void
 ModuleImpl::activate()
 {
-       if (!mActive)
-       {
-               session()->init();
-               // @@@ install handler here (use central dispatch with override)
-               secdebug("callback","In ModuleImpl::activate, mAppNotifyCallback=%p, mAppNotifyCallbackCtx=%p",
-                       mAppNotifyCallback, mAppNotifyCallbackCtx);
-               check(CSSM_ModuleLoad(&guid(), CSSM_KEY_HIERARCHY_NONE, mAppNotifyCallback, mAppNotifyCallbackCtx));
-               mActive = true;
-               session()->catchExit();
-       }
+    {
+        StLock<Mutex> _(mActivateMutex);
+        if (!mActive)
+        {
+            session()->init();
+            // @@@ install handler here (use central dispatch with override)
+            secdebug("callback","In ModuleImpl::activate, mAppNotifyCallback=%p, mAppNotifyCallbackCtx=%p",
+                mAppNotifyCallback, mAppNotifyCallbackCtx);
+            check(CSSM_ModuleLoad(&guid(), CSSM_KEY_HIERARCHY_NONE, mAppNotifyCallback, mAppNotifyCallbackCtx));
+            mActive = true;
+        }
+    }
+    
+    session()->catchExit();
 }
 
 void
 }
 
 void
@@ -413,6 +422,8 @@ ModuleImpl::deactivate()
 {
        if (!isIdle())
                Error::throwMe(Error::objectBusy);
 {
        if (!isIdle())
                Error::throwMe(Error::objectBusy);
+
+    StLock<Mutex> _(mActivateMutex);
        if (mActive)
        {
                mActive = false;
        if (mActive)
        {
                mActive = false;
@@ -463,6 +474,7 @@ AttachmentImpl::make(CSSM_SERVICE_TYPE subserviceType)
 void
 AttachmentImpl::activate()
 {
 void
 AttachmentImpl::activate()
 {
+    StLock<Mutex> _(mActivateMutex);
        if (!mActive)
        {
                module()->load();
        if (!mActive)
        {
                module()->load();
@@ -483,6 +495,7 @@ AttachmentImpl::activate()
 void
 AttachmentImpl::deactivate()
 {
 void
 AttachmentImpl::deactivate()
 {
+    StLock<Mutex> _(mActivateMutex);
        if (mActive)
        {
                mActive = false;
        if (mActive)
        {
                mActive = false;