[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "x_safe_constructors" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Jul 17 17:57:17 CDT 2012
branch "x_safe_constructors" has been updated
via e6b65c10643898b1ac0109a3f42bc3ef09753cbe (commit)
from dfa8647bf2e31c8de9cc0a7617049b061ed8ed9f (commit)
Summary of changes:
src/SIPEndpoint.cpp | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit e6b65c10643898b1ac0109a3f42bc3ef09753cbe
Author: Brent Eagles <beagles at digium.com>
Date: Tue Jul 17 20:25:43 2012 -0230
The mSessions vector was modifiable directly by SIPsession and whatever
operations initiated creation of sessions, however there was no lock around
modifying or reading the collection. I suspect this is what has been
causing our nasty SIP component bug.
diff --git a/src/SIPEndpoint.cpp b/src/SIPEndpoint.cpp
index 5cd7a73..55f04c9 100644
--- a/src/SIPEndpoint.cpp
+++ b/src/SIPEndpoint.cpp
@@ -278,6 +278,11 @@ public:
std::map<std::string, SIPRegistrationClientPtr> mClientRegistrations;
AsteriskSCF::Collections::HandleSet<AsteriskSCF::SessionCommunications::V1::SessionCookiePtr>::SetPtr mDefaultSessionCookies;
AsteriskSCF::Operations::OperationContextCachePtr mOperationContextCache;
+
+ //
+ // Temporary (?) fix for race conditions where multiple sessions for an Endpoint might actually be alive at a given time.
+ //
+ boost::mutex mSessionsLock;
};
SIPEndpoint::SIPEndpoint(const Ice::ObjectAdapterPtr& adapter,
@@ -595,7 +600,10 @@ AsteriskSCF::SessionCommunications::V1::SessionPrx SIPEndpoint::createSession(
mImplPriv->mConfig.sessionConfig.udptlOverICE,
mImplPriv->mConfig.sessionConfig.udptlWithTURN));
- mImplPriv->mSessions.push_back(session);
+ {
+ boost::lock_guard<boost::mutex> lock(mImplPriv->mSessionsLock);
+ mImplPriv->mSessions.push_back(session);
+ }
std::cout << "And now we're returing a session proxy..." << std::endl;
@@ -639,6 +647,7 @@ AsteriskSCF::SIPSessionGateway::SIPSessionPtr SIPEndpoint::createSession(const s
mImplPriv->mConfig.sessionConfig.udptlWithTURN)
);
+ boost::lock_guard<boost::mutex> lock(mImplPriv->mSessionsLock);
mImplPriv->mSessions.push_back(session);
return session;
}
@@ -683,6 +692,7 @@ SIPSessionPtr SIPEndpoint::createSession
mImplPriv->mConfig.sessionConfig.udptlOverICE,
mImplPriv->mConfig.sessionConfig.udptlWithTURN));
+ boost::lock_guard<boost::mutex> lock(mImplPriv->mSessionsLock);
mImplPriv->mSessions.push_back(session);
return session;
}
@@ -695,6 +705,7 @@ SIPSessionPtr SIPEndpoint::createSession
void SIPEndpoint::removeSession(const AsteriskSCF::SessionCommunications::V1::SessionPtr& session)
{
SIPSessionPtr sipsession = SIPSessionPtr::dynamicCast(session);
+ boost::lock_guard<boost::mutex> lock(mImplPriv->mSessionsLock);
mImplPriv->mSessions.erase(std::remove(mImplPriv->mSessions.begin(), mImplPriv->mSessions.end(), sipsession),
mImplPriv->mSessions.end());
}
@@ -702,6 +713,7 @@ void SIPEndpoint::removeSession(const AsteriskSCF::SessionCommunications::V1::Se
AsteriskSCF::SessionCommunications::V1::SessionSeq SIPEndpoint::getSessions(const Ice::Current&)
{
AsteriskSCF::SessionCommunications::V1::SessionSeq sessions;
+ boost::lock_guard<boost::mutex> lock(mImplPriv->mSessionsLock);
for (std::vector<SIPSessionPtr>::const_iterator session = mImplPriv->mSessions.begin();
session != mImplPriv->mSessions.end(); ++session)
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list