[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "alternate_source_cleanup" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Jul 9 15:33:53 CDT 2012
branch "alternate_source_cleanup" has been updated
via 33d85fe523555ae4ab637ca62f09da3b6b8a91c7 (commit)
from f0e6255ca9fe653b034055d82df3cd48319ad3dc (commit)
Summary of changes:
src/TransportMap.cpp | 64 ++++++++++++++++++++++++++++++-------------------
1 files changed, 39 insertions(+), 25 deletions(-)
- Log -----------------------------------------------------------------
commit 33d85fe523555ae4ab637ca62f09da3b6b8a91c7
Author: Brent Eagles <beagles at digium.com>
Date: Mon Jul 9 18:03:31 2012 -0230
Fixed some deadlock conditions that occur pretty readily in live testing.
diff --git a/src/TransportMap.cpp b/src/TransportMap.cpp
index 07d5045..e8fc5f5 100755
--- a/src/TransportMap.cpp
+++ b/src/TransportMap.cpp
@@ -65,7 +65,7 @@ void TransportMap::addTransport(const MapRecord& r, const string& ip, Ice::Int p
{
assert(r.transport);
assert(r.source);
- boost::unique_lock<boost::shared_mutex> lock(mLock);
+ MapRecord oldRecord;
AddressPtr address = r.transport->localAddress();
assert(address);
unsigned tblIndex = address->port() / 1000;
@@ -82,15 +82,25 @@ void TransportMap::addTransport(const MapRecord& r, const string& ip, Ice::Int p
throw AsteriskSCF::Media::RTP::V1::InvalidAddress();
}
- //
- // Lazy initialization of port subtables.
- //
- if (mTable[tblIndex].size() < (arrayIndex + 1))
{
- mTable[tblIndex].resize(arrayIndex + 1);
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+
+ //
+ // Lazy initialization of port subtables.
+ //
+ if (mTable[tblIndex].size() < (arrayIndex + 1))
+ {
+ mTable[tblIndex].resize(arrayIndex + 1);
+ }
+
+ oldRecord = mTable[tblIndex][arrayIndex];
+ mTable[tblIndex][arrayIndex] = r;
+ if (oldRecord.transport == 0)
+ {
+ incEntries();
+ }
}
- MapRecord oldRecord = mTable[tblIndex][arrayIndex];
if (oldRecord.transport != 0)
{
lg(Debug) << "Updating existing transport entry";
@@ -102,7 +112,6 @@ void TransportMap::addTransport(const MapRecord& r, const string& ip, Ice::Int p
}
}
- mTable[tblIndex][arrayIndex] = r;
pj_status_t result;
if (rtcp)
{
@@ -118,6 +127,8 @@ void TransportMap::addTransport(const MapRecord& r, const string& ip, Ice::Int p
}
if (result != PJ_SUCCESS)
{
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+
//
// Do we revert the system or simply set to a sane initial
// state? We cannot really re-attach because we don't have all
@@ -125,39 +136,42 @@ void TransportMap::addTransport(const MapRecord& r, const string& ip, Ice::Int p
// state for now.
//
mTable[tblIndex][arrayIndex] = MapRecord();
+ decEntries();
throw AsteriskSCF::Media::RTP::V1::InvalidAddress();
}
- if (oldRecord.transport == 0)
- {
- incEntries();
- }
}
void TransportMap::removeTransport(const MapRecord& r)
{
- boost::unique_lock<boost::shared_mutex> lock(mLock);
- AddressPtr address = r.transport->localAddress();
- assert(address);
- unsigned tblIndex = address->port() / 1000;
- unsigned arrayIndex = address->port() % 1000;
- if (mTable[tblIndex].size() < (arrayIndex + 1) || mTable[tblIndex][arrayIndex].transport == 0)
+ MapRecord toRemove;
+ int port;
{
- lg(Debug) << "Attempting to remove a non-existant transport";
- return;
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ AddressPtr address = r.transport->localAddress();
+ assert(address);
+ port = address->port();
+ unsigned tblIndex = port / 1000;
+ unsigned arrayIndex = port % 1000;
+ if (mTable[tblIndex].size() < (arrayIndex + 1) || mTable[tblIndex][arrayIndex].transport == 0)
+ {
+ lg(Debug) << "Attempting to remove a non-existent transport";
+ return;
+ }
+ toRemove = mTable[tblIndex][arrayIndex];
+ mTable[tblIndex][arrayIndex] = MapRecord();
+ decEntries();
}
- MapRecord toRemove = mTable[tblIndex][arrayIndex];
+
if (toRemove.transport != 0)
{
pjmedia_transport* t = toRemove.transport->getTransport();
if (t)
{
- pjmedia_transport_detach(t, reinterpret_cast<void*>(address->port()));
+ pjmedia_transport_detach(t, reinterpret_cast<void*>(port));
}
}
-
- mTable[tblIndex][arrayIndex] = MapRecord();
- decEntries();
+
}
TransportMap& TransportMap::instance()
-----------------------------------------------------------------------
--
asterisk-scf/integration/media_rtp_pjmedia.git
More information about the asterisk-scf-commits
mailing list