[asterisk-scf-commits] asterisk-scf/release/sip.git branch "authexten" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Thu Mar 3 14:36:53 CST 2011
branch "authexten" has been updated
via 572289496c4142e8cc748cfb641efd846b2a8dc0 (commit)
via d4899c06c3c254cdff2ceb2db6d2121dc6ad1f01 (commit)
from 69d20d88cd1823c628ac51fdb9d5c86f545deede (commit)
Summary of changes:
src/AuthManager.cpp | 38 ++++++++++++++++++++++----------------
src/AuthManager.h | 6 +++---
2 files changed, 25 insertions(+), 19 deletions(-)
- Log -----------------------------------------------------------------
commit 572289496c4142e8cc748cfb641efd846b2a8dc0
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Mar 3 13:59:30 2011 -0600
Create the visitor on the heap.
diff --git a/src/AuthManager.cpp b/src/AuthManager.cpp
index c8ee909..f6e97f1 100644
--- a/src/AuthManager.cpp
+++ b/src/AuthManager.cpp
@@ -231,9 +231,10 @@ void AuthInstance::addDigests(pjsip_tx_data *tdata, const DigestChallengeSeq &di
pj_str_t *mNonce;
pj_str_t **mNoncePtr;
- } v(&nonce, &noncePtr);
+ };
- (*digest)->visit(&v);
+ DigestChallengeVisitorPtr v = new visitor(&nonce, &noncePtr);
+ (*digest)->visit(v);
pjsip_auth_srv_challenge(authServer, &pjqop, noncePtr, opaquePtr, PJ_FALSE, tdata);
mImpl->authServers.push_back(authServer);
commit d4899c06c3c254cdff2ceb2db6d2121dc6ad1f01
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Mar 3 11:25:25 2011 -0600
Create and release a pool for each AuthInstance.
The previous model created a single pool for the authmanager
and then released the pool when the authmanager went away. This
could cause a large memory leak over time if lots of requests
are challenged.
This also fixed a rather grievous error where the AuthManagerPriv
never set its mEndpoint member.
diff --git a/src/AuthManager.cpp b/src/AuthManager.cpp
index cbed459..c8ee909 100644
--- a/src/AuthManager.cpp
+++ b/src/AuthManager.cpp
@@ -49,8 +49,9 @@ class AuthInstancePriv
{
public:
AuthInstancePriv(pjsip_rx_data *rdata, const moduleHookVector &moduleHooks,
- RequestType type, pj_pool_t *pool, const Logger &logger)
- : mPool(pool), mLogger(logger),
+ RequestType type, pjsip_endpoint *endpoint, const Logger &logger)
+ : mEndpoint(endpoint), mPool(pjsip_endpt_create_pool(mEndpoint, "auth%p", 500, 256)),
+ mLogger(logger),
fromTag(pj_strbuf(&rdata->msg_info.from->tag), pj_strlen(&rdata->msg_info.from->tag)),
callId(pj_strbuf(&rdata->msg_info.cid->id), pj_strlen(&rdata->msg_info.cid->id))
{
@@ -73,6 +74,11 @@ public:
}
}
+ ~AuthInstancePriv()
+ {
+ pjsip_endpt_release_pool(mEndpoint, mPool);
+ }
+
void getURIParams(const pjsip_uri *uri, ParamDict ¶ms)
{
pjsip_sip_uri *sipURI = (pjsip_sip_uri *) pjsip_uri_get_uri(uri);
@@ -119,6 +125,7 @@ public:
std::vector<AuthHookPrx> hooks;
std::vector<pjsip_auth_srv *> authServers;
+ pjsip_endpoint *mEndpoint;
pj_pool_t *mPool;
pj_timer_entry entry;
Logger mLogger;
@@ -127,8 +134,8 @@ public:
};
AuthInstance::AuthInstance(pjsip_rx_data *rdata, const moduleHookVector &hooks,
- RequestType type, pj_pool_t *pool, const Logger &logger)
- : mImpl(new AuthInstancePriv(rdata, hooks, type, pool, logger)) { }
+ RequestType type, pjsip_endpoint *endpoint, const Logger &logger)
+ : mImpl(new AuthInstancePriv(rdata, hooks, type, endpoint, logger)) { }
std::vector<AuthHookPrx> AuthInstance::getHooks()
{
@@ -181,11 +188,11 @@ bool AuthInstance::authenticate(pjsip_rx_data *rdata)
return false;
}
-void AuthInstance::scheduleAuthTimeout(pjsip_endpoint *endpt, int id)
+void AuthInstance::scheduleAuthTimeout(int id)
{
const pj_time_val time = {60, 0};
pj_timer_entry_init(&mImpl->entry, id, this, sessionAuthTimeout);
- pjsip_endpt_schedule_timer(endpt, &mImpl->entry, &time);
+ pjsip_endpt_schedule_timer(mImpl->mEndpoint, &mImpl->entry, &time);
}
void AuthInstance::addDigests(pjsip_tx_data *tdata, const DigestChallengeSeq &digests)
@@ -311,27 +318,25 @@ bool AuthInstance::isEqual(const std::string &fromTag, const std::string &callId
return fromTag == mImpl->fromTag && callId == mImpl->callId;
}
-void AuthInstance::cancelAuthTimeout(pjsip_endpoint *endpt)
+void AuthInstance::cancelAuthTimeout()
{
- pjsip_endpt_cancel_timer(endpt, &mImpl->entry);
+ pjsip_endpt_cancel_timer(mImpl->mEndpoint, &mImpl->entry);
}
class AuthManagerPriv
{
public:
AuthManagerPriv(pjsip_endpoint *endpt, const Logger &logger)
- : mPool(pjsip_endpt_create_pool(endpt, "auth%p", 1200, 512)),
+ : mEndpoint(endpt),
mLogger(logger) { }
~AuthManagerPriv()
{
mAuthInstances.erase(mAuthInstances.begin(), mAuthInstances.end());
- pjsip_endpt_release_pool(mEndpoint, mPool);
}
std::vector<boost::shared_ptr<AuthInstance> > mAuthInstances;
pjsip_endpoint *mEndpoint;
- pj_pool_t *mPool;
moduleHookVector mRegisteredHooks;
Logger mLogger;
int mCounter;
@@ -352,7 +357,7 @@ boost::shared_ptr<AuthInstance> AuthManager::createAuthInstance(pjsip_rx_data *r
{
boost::lock_guard<boost::mutex> hookLock(mImpl->mHooksLock);
instance.reset(new AuthInstance(rdata, mImpl->mRegisteredHooks,
- type, mImpl->mPool, mImpl->mLogger));
+ type, mImpl->mEndpoint, mImpl->mLogger));
}
boost::lock_guard<boost::mutex> instancesLock(mImpl->mAuthInstancesLock);
mImpl->mAuthInstances.push_back(instance);
@@ -376,7 +381,7 @@ bool AuthManager::authenticate(pjsip_rx_data *rdata)
{
//If authentication has succeeded, then we can remove this AuthInstance
//from our list, and we need to cancel the scheduled task
- (*iter)->cancelAuthTimeout(mImpl->mEndpoint);
+ (*iter)->cancelAuthTimeout();
mImpl->mAuthInstances.erase(iter);
return true;
}
@@ -402,7 +407,7 @@ void AuthManager::destroyAuthInstance(const boost::shared_ptr<AuthInstance> &ins
void AuthManager::scheduleAuthTimeout(const boost::shared_ptr<AuthInstance> &instance)
{
- instance->scheduleAuthTimeout(mImpl->mEndpoint, mImpl->mCounter++);
+ instance->scheduleAuthTimeout(mImpl->mCounter++);
}
void AuthManager::authTimeout(pj_timer_heap_t *timer_heap, pj_timer_entry *entry)
diff --git a/src/AuthManager.h b/src/AuthManager.h
index d70dc77..7832549 100644
--- a/src/AuthManager.h
+++ b/src/AuthManager.h
@@ -49,7 +49,7 @@ public:
AuthInstance(pjsip_rx_data *rdata,
const moduleHookVector &hooks,
AsteriskSCF::SIP::ExtensionPoint::V1::RequestType type,
- pj_pool_t *pool,
+ pjsip_endpoint *endpoint,
const AsteriskSCF::System::Logging::Logger &logger);
/**
@@ -87,12 +87,12 @@ public:
* so that the id parameter can be guaranteed to be unique per
* AuthInstance.
*/
- void scheduleAuthTimeout(pjsip_endpoint *endpt, int id);
+ void scheduleAuthTimeout(int id);
/**
* Cancel the current scheduled auth timeout task on the AuthInstance.
*/
- void cancelAuthTimeout(pjsip_endpoint *endpt);
+ void cancelAuthTimeout();
/**
* Determine if this AuthInstance matches a message with the given
-----------------------------------------------------------------------
--
asterisk-scf/release/sip.git
More information about the asterisk-scf-commits
mailing list