[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "auth" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Aug 3 14:01:03 CDT 2011


branch "auth" has been updated
       via  3555e9a4c6880f67257cc33f3ba56c34064752dd (commit)
       via  a458f985171c966cd71b53bd711b62179ece4f01 (commit)
      from  495836a1a62f961160d46cde236e57a1f7a5bf39 (commit)

Summary of changes:
 src/AuthManager.cpp |   17 +++++++++++++++--
 src/AuthManager.h   |    4 ++++
 src/PJSipModule.cpp |   15 ++++++++++++---
 3 files changed, 31 insertions(+), 5 deletions(-)


- Log -----------------------------------------------------------------
commit 3555e9a4c6880f67257cc33f3ba56c34064752dd
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Aug 3 16:00:49 2011 -0300

    Instead of creating a boost::shared_ptr out of thin air which is made just do a bare pointer comparison to find, remove, and destroy the AuthInstance.

diff --git a/src/AuthManager.cpp b/src/AuthManager.cpp
index 075a909..c9934c1 100644
--- a/src/AuthManager.cpp
+++ b/src/AuthManager.cpp
@@ -394,6 +394,20 @@ void AuthManager::destroyAuthInstance(const boost::shared_ptr<AuthInstance> &ins
     }
 }
 
+void AuthManager::destroyAuthInstance(const AuthInstance* instance)
+{
+    boost::lock_guard<boost::mutex> lock(mImpl->mAuthInstancesLock);
+    for (std::vector<boost::shared_ptr<AuthInstance> >::iterator iter = mImpl->mAuthInstances.begin();
+	 iter != mImpl->mAuthInstances.end(); ++ iter)
+    {
+        if ((*iter).get() == instance)
+        {
+            mImpl->mAuthInstances.erase(iter);
+            break;
+        }
+    }
+}
+
 void AuthManager::scheduleAuthTimeout(const boost::shared_ptr<AuthInstance> &instance)
 {
     instance->scheduleAuthTimeout(mImpl->mCounter++);
@@ -401,8 +415,7 @@ void AuthManager::scheduleAuthTimeout(const boost::shared_ptr<AuthInstance> &ins
 
 void AuthManager::authTimeout(pj_timer_heap_t *, pj_timer_entry *entry)
 {
-    boost::shared_ptr<AuthInstance> killMe(static_cast<AuthInstance *>(entry->user_data));
-    destroyAuthInstance(killMe);
+    destroyAuthInstance(static_cast<AuthInstance *>(entry->user_data));
 }
 
 void AuthManager::addAuthHook(const AsteriskSCF::SIP::ExtensionPoint::V1::AuthHookPrx &hook,
diff --git a/src/AuthManager.h b/src/AuthManager.h
index 07930ab..f113ea0 100644
--- a/src/AuthManager.h
+++ b/src/AuthManager.h
@@ -158,6 +158,10 @@ public:
      */
     void destroyAuthInstance(const boost::shared_ptr<AuthInstance> &instance);
     /**
+     * Destroy an AuthInstance
+     */
+    void destroyAuthInstance(const AuthInstance* instance);
+    /**
      * This is the callback that scheduleAuthDestruction sets up.
      *
      * Do not call this method directly.

commit a458f985171c966cd71b53bd711b62179ece4f01
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Aug 3 14:23:00 2011 -0300

    Make the AuthManager optional on modules.

diff --git a/src/PJSipModule.cpp b/src/PJSipModule.cpp
index 12497e4..5a85362 100644
--- a/src/PJSipModule.cpp
+++ b/src/PJSipModule.cpp
@@ -160,17 +160,26 @@ TransactionState PJSipTransactionModInfo::transactionStateTranslate(pjsip_tsx_st
 
 void PJSipModule::addAuthHook(const AsteriskSCF::SIP::ExtensionPoint::V1::AuthHookPrx &hook, int priority, const AsteriskSCF::SIP::ExtensionPoint::V1::RequestTypeSeq &types)
 {
-    mAuthManager->addAuthHook(hook, priority, types);
+    if (mAuthManager.get())
+    {
+        mAuthManager->addAuthHook(hook, priority, types);
+    }
 }
 
 void PJSipModule::removeAuthHook(const AsteriskSCF::SIP::ExtensionPoint::V1::AuthHookPrx &hook)
 {
-    mAuthManager->removeAuthHook(hook);
+    if (mAuthManager.get())
+    {
+        mAuthManager->removeAuthHook(hook);
+    }
 }
 
 void PJSipModule::clearAuthHooks()
 {
-    mAuthManager->clearAuthHooks();
+    if (mAuthManager.get())
+    {
+        mAuthManager->clearAuthHooks();
+    }
 }
 
 };

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list