X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/b1ab9ed8d0e0f1c3b66d7daa8fd5564444c56195..420ff9d9379a8d93f2c90f026a797bdea1eb4517:/libsecurity_cdsa_client/lib/cssmclient.cpp?ds=sidebyside diff --git a/libsecurity_cdsa_client/lib/cssmclient.cpp b/libsecurity_cdsa_client/lib/cssmclient.cpp index ec3fb44d..dc091bb5 100644 --- a/libsecurity_cdsa_client/lib/cssmclient.cpp +++ b/libsecurity_cdsa_client/lib/cssmclient.cpp @@ -30,7 +30,7 @@ // and thus don't need to be interlocked explicitly. // #include - +#include using namespace CssmClient; @@ -77,8 +77,11 @@ ObjectImpl::ObjectImpl(const Object &mommy) : mParent(mommy.mImpl), mChildCount( 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) @@ -193,6 +196,7 @@ CssmImpl::standard() void CssmImpl::activate() { + StLock _(mActivateMutex); if (!mActive) { // currently, no choices on PVC mode and key hierarchy @@ -213,6 +217,7 @@ CssmImpl::activate() void CssmImpl::deactivate() { + StLock _(mActivateMutex); if (mActive) { mActive = false; @@ -396,16 +401,20 @@ ModuleImpl::appNotifyCallback(RawModuleEvents *handler) 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 _(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 @@ -413,6 +422,8 @@ ModuleImpl::deactivate() { if (!isIdle()) Error::throwMe(Error::objectBusy); + + StLock _(mActivateMutex); if (mActive) { mActive = false; @@ -463,6 +474,7 @@ AttachmentImpl::make(CSSM_SERVICE_TYPE subserviceType) void AttachmentImpl::activate() { + StLock _(mActivateMutex); if (!mActive) { module()->load(); @@ -483,6 +495,7 @@ AttachmentImpl::activate() void AttachmentImpl::deactivate() { + StLock _(mActivateMutex); if (mActive) { mActive = false;