[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "registrar" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Thu Jun 16 09:11:19 CDT 2011
branch "registrar" has been updated
via 706a6986e046909d0035038412d759ba1e6c199c (commit)
via 1624b232fe8cd35ab4a88ae0aa7d74498d98e3c9 (commit)
via 591d2f8183dbed4dce5734ae09e5c2d2cb2de8c3 (commit)
via ae5e868cf90a06e489748299eca32564f248d52b (commit)
from 1a6d54ba8e42b022e2dea6c696ab26ebac0345a2 (commit)
Summary of changes:
src/CMakeLists.txt | 2 +
src/PJSipManager.cpp | 6 +-
src/PJSipManager.h | 2 +-
src/PJSipRegistrarModule.cpp | 43 ++++++++++---
src/PJSipRegistrarModule.h | 5 +-
src/PJSipRegistrarModuleConstruction.cpp | 6 +-
src/SipEndpoint.h | 2 +
src/SipEndpointFactory.cpp | 15 ++++-
src/SipEndpointFactory.h | 2 +
src/SipRegistrarListener.cpp | 101 ++++++++++++++++++++++++++++++
src/SipRegistrarListener.h | 46 ++++++++++++++
src/SipSessionManagerApp.cpp | 16 +++++-
12 files changed, 228 insertions(+), 18 deletions(-)
create mode 100644 src/SipRegistrarListener.cpp
create mode 100644 src/SipRegistrarListener.h
- Log -----------------------------------------------------------------
commit 706a6986e046909d0035038412d759ba1e6c199c
Author: Mark Michelson <mmichelson at digium.com>
Date: Wed Jun 15 17:36:42 2011 -0500
Change operations on the SipDefaultRegistrarListener a bit.
This makes them a bit more flexible and will cause less work once
endpoints can support multiple AoRs/contacts.
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index 40a8e25..187c904 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -285,6 +285,8 @@ private:
*/
typedef IceUtil::Handle<SipEndpoint> SipEndpointPtr;
+typedef std::vector<SipEndpointPtr> SipEndpointSeq;
+
}; //End namespace SipSessionManager
}; //End namespace AsteriskSCF
diff --git a/src/SipRegistrarListener.cpp b/src/SipRegistrarListener.cpp
index 4a375e8..b351585 100644
--- a/src/SipRegistrarListener.cpp
+++ b/src/SipRegistrarListener.cpp
@@ -32,21 +32,59 @@ namespace SipSessionManager
using namespace AsteriskSCF::SIP::Registration::V1;
SipDefaultRegistrarListener::SipDefaultRegistrarListener(const boost::shared_ptr<SipEndpointFactory>& endpointFactory)
- : mEndpointFactory(endpointFactory) { }
+ : mEndpointFactory(endpointFactory)
+{
+ pj_caching_pool_init(&mCachingPool, NULL, 2048);
+}
SipDefaultRegistrarListener::~SipDefaultRegistrarListener() { }
+SipEndpointSeq SipDefaultRegistrarListener::getEndpoints(pj_pool_t *pool, const std::string& aor)
+{
+ pjsip_uri *aorURI = pjsip_parse_uri(pool, (char *)aor.c_str(), aor.size(), 0);
+ pjsip_sip_uri *aorSipURI = (pjsip_sip_uri *) pjsip_uri_get_uri(aorURI);
+ //Currently we're just using the user portion of the AoR to find a single endpoint.
+ //This portion can be redone once we can get multiple endpoints from an AoR.
+ std::string aorUser(pj_strbuf(&aorSipURI->user), pj_strlen(&aorSipURI->user));
+ lg(Debug) << "Extracted endpoint name " << aorUser << " from aor";
+ SipEndpointPtr endpoint = mEndpointFactory->findByName(aorUser);
+ SipEndpointSeq endpointSeq;
+ endpointSeq.push_back(endpoint);
+ return endpointSeq;
+}
+
+void SipDefaultRegistrarListener::updateEndpoints(const SipEndpointSeq& endpoints, pj_pool_t *pool, const std::string& contact)
+{
+ pjsip_uri *contactURI = pjsip_parse_uri(pool, (char *)contact.c_str(), contact.size(), 0);
+ pjsip_sip_uri *contactSipURI = (pjsip_sip_uri *) pjsip_uri_get_uri(contactURI);
+ std::string contactHost(pj_strbuf(&contactSipURI->host), pj_strlen(&contactSipURI->host));
+ lg(Debug) << "Extracted host " << contactHost << " from contact";
+ int port = contactSipURI->port;
+ lg(Debug) << "Extracted port " << port << " from contact";
+ for (SipEndpointSeq::const_iterator iter = endpoints.begin(); iter != endpoints.end(); ++iter)
+ {
+ lg(Debug) << "Adding new contact " << contactHost << ":" << port << " to endpoint " << (*iter)->getName();
+ //Currently, all we do is update the single target host/port that an endpoint can have configured.
+ //This part can be edited once endpoints can have multiple contacts associated with an AoR
+ (*iter)->setTargetAddress(contactHost, port);
+ }
+}
+
void SipDefaultRegistrarListener::contactsAdded(const BindingUpdateSeq& contacts, const Ice::Current&)
{
+ pj_pool_t *pool = pj_pool_create(&mCachingPool.factory, "DefaultRegistrarListener", 256, 256, NULL);
for (BindingUpdateSeq::const_iterator iter = contacts.begin(); iter != contacts.end(); ++iter)
{
+ SipEndpointSeq endpoints = getEndpoints(pool, iter->aor);
for (Ice::StringSeq::const_iterator contactIter = iter->contacts.begin();
contactIter != iter->contacts.end(); ++contactIter)
{
- lg(Debug) << "Adding new contact " << *contactIter << " to AoR " << iter->aor;
+ updateEndpoints(endpoints, pool, *contactIter);
}
}
+ pj_pool_release(pool);
}
+
void SipDefaultRegistrarListener::contactsRemoved(const BindingUpdateSeq& contacts, const Ice::Current&)
{
for (BindingUpdateSeq::const_iterator iter = contacts.begin(); iter != contacts.end(); ++iter)
diff --git a/src/SipRegistrarListener.h b/src/SipRegistrarListener.h
index 973d330..fbe7feb 100644
--- a/src/SipRegistrarListener.h
+++ b/src/SipRegistrarListener.h
@@ -16,6 +16,8 @@
#pragma once
+#include <pjsip.h>
+#include <pjlib.h>
#include <AsteriskSCF/SIP/SIPRegistrarIf.h>
#include "SipEndpointFactory.h"
@@ -34,7 +36,10 @@ public:
void contactsAdded(const AsteriskSCF::SIP::Registration::V1::BindingUpdateSeq&, const Ice::Current&);
void contactsRemoved(const AsteriskSCF::SIP::Registration::V1::BindingUpdateSeq&, const Ice::Current&);
private:
+ SipEndpointSeq getEndpoints(pj_pool_t *pool, const std::string& aor);
+ void updateEndpoints(const SipEndpointSeq& endpoints, pj_pool_t *pool, const std::string& contact);
boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
+ pj_caching_pool mCachingPool;
};
} // namespace SipSessionManager
commit 1624b232fe8cd35ab4a88ae0aa7d74498d98e3c9
Author: Mark Michelson <mmichelson at digium.com>
Date: Wed Jun 15 14:55:03 2011 -0500
Add a default registrar listener to the registrar.
I have tested that it is properly updated when the registrar
receives REGISTER messages. Now I need to make the listener
update endpoint configuration.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a10e59f..5e1b573 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -39,6 +39,8 @@ asterisk_scf_component_add_file(SipSessionManager SipConfiguration.cpp)
asterisk_scf_component_add_file(SipSessionManager SipConfiguration.h)
asterisk_scf_component_add_file(SipSessionManager SipStateReplicatorListener.cpp)
asterisk_scf_component_add_file(SipSessionManager SipStateReplicator.h)
+asterisk_scf_component_add_file(SipSessionManager SipRegistrarListener.cpp)
+asterisk_scf_component_add_file(SipSessionManager SipRegistrarListener.h)
asterisk_scf_component_add_slice(SipSessionManager ../local-slice/SipIf.ice)
asterisk_scf_component_add_slice(SipSessionManager ../local-slice/SipStateReplicationIf.ice)
asterisk_scf_component_add_slice(SipSessionManager ../local-slice/SipConfigurationIf.ice)
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index ef525df..bbcad80 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -33,6 +33,8 @@ namespace AsteriskSCF
namespace SipSessionManager
{
+using namespace AsteriskSCF::SIP::Registration::V1;
+
static void *monitorThread(void *endpt)
{
pjsip_endpoint *endpoint = static_cast<pjsip_endpoint *> (endpt);
@@ -93,9 +95,9 @@ void PJSipManager::registerLoggingModule()
mLoggingModule = new PJSipLoggingModule(mEndpoint);
}
-void PJSipManager::registerRegistrarModule()
+void PJSipManager::registerRegistrarModule(const RegistrarListenerPrx& defaultListener)
{
- mRegistrarModule = new PJSipRegistrarModule(mEndpoint);
+ mRegistrarModule = new PJSipRegistrarModule(mEndpoint, defaultListener);
}
PJSipSessionModulePtr PJSipManager::getSessionModule()
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index 024da4b..f90e46b 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -89,7 +89,7 @@ public:
* for keeping track of bindings of contact URIs to
* addresses of record.
*/
- void registerRegistrarModule();
+ void registerRegistrarModule(const AsteriskSCF::SIP::Registration::V1::RegistrarListenerPrx& defaultListener);
/**
* Create a UDP transport.
diff --git a/src/PJSipRegistrarModule.cpp b/src/PJSipRegistrarModule.cpp
index 9d4334a..ec92bb9 100644
--- a/src/PJSipRegistrarModule.cpp
+++ b/src/PJSipRegistrarModule.cpp
@@ -94,12 +94,18 @@ void BindingHolder::updateBinding(const std::string &callID, int cSeq, int expir
scheduleRegistrationExpiration(expiration);
}
-RegistrarI::RegistrarI() { }
+RegistrarI::RegistrarI(const RegistrarListenerPrx& defaultListener)
+{
+ Ice::Current barf;
+ lg(Debug) << "In RegistrarI constructor, should be adding a listener...";
+ addListener(defaultListener, barf);
+}
ContactDict RegistrarI::addListener(const RegistrarListenerPrx& listener, const Ice::Current&)
{
- if (std::find(mListeners.begin(), mListeners.end(), listener) != mListeners.end())
+ if (std::find(mListeners.begin(), mListeners.end(), listener) == mListeners.end())
{
+ lg(Debug) << "Adding Listener " << listener->ice_getIdentity().name << " to registrar";
mListeners.push_back(listener);
}
//We should maybe throw an exception if someone tries to insert a duplicate?
diff --git a/src/PJSipRegistrarModule.h b/src/PJSipRegistrarModule.h
index 8c759ce..ff568b2 100644
--- a/src/PJSipRegistrarModule.h
+++ b/src/PJSipRegistrarModule.h
@@ -62,7 +62,7 @@ typedef std::map<std::string, BindingHolderSeq> BindingHolderDict;
class RegistrarI : public AsteriskSCF::SIP::Registration::V1::Registrar
{
public:
- RegistrarI();
+ RegistrarI(const AsteriskSCF::SIP::Registration::V1::RegistrarListenerPrx& defaultListener);
AsteriskSCF::SIP::Registration::V1::ContactDict addListener(const AsteriskSCF::SIP::Registration::V1::RegistrarListenerPrx& listener, const Ice::Current&);
void removeListener(const AsteriskSCF::SIP::Registration::V1::RegistrarListenerPrx& listener, const Ice::Current&);
AsteriskSCF::SIP::Registration::V1::BindingDict getAllBindings(const Ice::Current&);
@@ -91,7 +91,7 @@ private:
class PJSipRegistrarModule : public PJSipModule
{
public:
- PJSipRegistrarModule(pjsip_endpoint *endpt);
+ PJSipRegistrarModule(pjsip_endpoint *endpt, const AsteriskSCF::SIP::Registration::V1::RegistrarListenerPrx& defaultListener);
pj_status_t load(pjsip_endpoint *endpoint);
pj_status_t start();
pj_status_t stop();
diff --git a/src/PJSipRegistrarModuleConstruction.cpp b/src/PJSipRegistrarModuleConstruction.cpp
index a4aeeeb..9ec6148 100644
--- a/src/PJSipRegistrarModuleConstruction.cpp
+++ b/src/PJSipRegistrarModuleConstruction.cpp
@@ -16,6 +16,8 @@
#include "PJSipRegistrarModule.h"
+using namespace AsteriskSCF::SIP::Registration::V1;
+
namespace AsteriskSCF
{
@@ -71,8 +73,8 @@ static void registrarOnTsxState(pjsip_transaction *tsx, pjsip_event *event)
return registrarModule->on_tsx_state(tsx, event);
}
-PJSipRegistrarModule::PJSipRegistrarModule(pjsip_endpoint *endpt)
- : mEndpoint(endpt), mRegistrar(new RegistrarI())
+PJSipRegistrarModule::PJSipRegistrarModule(pjsip_endpoint *endpt, const RegistrarListenerPrx& defaultListener)
+ : mEndpoint(endpt), mRegistrar(new RegistrarI(defaultListener))
{
registrarModule = this;
mModule.name = pj_str(registrarModuleName);
diff --git a/src/SipEndpointFactory.cpp b/src/SipEndpointFactory.cpp
index 09c4704..875ff84 100644
--- a/src/SipEndpointFactory.cpp
+++ b/src/SipEndpointFactory.cpp
@@ -14,14 +14,25 @@
* at the top of the source tree.
*/
+#include <AsteriskSCF/logger.h>
+
#include "SipEndpoint.h"
#include "SipEndpointFactory.h"
+using namespace AsteriskSCF::System::Logging;
+
+namespace
+{
+Logger lg = getLoggerFactory().getLogger("AsteriskSCF.SipSessionManager");
+}
+
namespace AsteriskSCF
{
namespace SipSessionManager
{
+using namespace AsteriskSCF::SIP::Registration::V1;
+
SipEndpointPtr SipEndpointFactory::createEndpoint(const std::string& destination, const Ice::PropertiesPtr& props)
{
std::string prefix("Sip.Endpoint.");
@@ -45,8 +56,8 @@ void SipEndpointFactory::remove(std::string endpointName)
SipEndpointPtr endpoint = findByName(endpointName);
if (endpoint != 0)
{
- endpoint->removeFromAdapter();
- mEndpoints.erase(std::remove(mEndpoints.begin(), mEndpoints.end(), endpoint), mEndpoints.end());
+ endpoint->removeFromAdapter();
+ mEndpoints.erase(std::remove(mEndpoints.begin(), mEndpoints.end(), endpoint), mEndpoints.end());
}
}
diff --git a/src/SipEndpointFactory.h b/src/SipEndpointFactory.h
index 48cfd97..5d81029 100644
--- a/src/SipEndpointFactory.h
+++ b/src/SipEndpointFactory.h
@@ -21,6 +21,7 @@
#include <boost/enable_shared_from_this.hpp>
#include <AsteriskSCF/Core/Endpoint/EndpointIf.h>
+#include <AsteriskSCF/SIP/SIPRegistrarIf.h>
namespace AsteriskSCF
{
@@ -49,6 +50,7 @@ public:
SipEndpointPtr findByName(const std::string& endpointName);
void generateRoutingDestinations(AsteriskSCF::Core::Routing::V1::RegExSeq&);
+
private:
/**
* A pointer to the object adapter that endpoints will be added to.
diff --git a/src/SipRegistrarListener.cpp b/src/SipRegistrarListener.cpp
new file mode 100644
index 0000000..4a375e8
--- /dev/null
+++ b/src/SipRegistrarListener.cpp
@@ -0,0 +1,63 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+#include <AsteriskSCF/logger.h>
+
+#include "SipRegistrarListener.h"
+
+using namespace AsteriskSCF::System::Logging;
+
+namespace
+{
+Logger lg = getLoggerFactory().getLogger("AsteriskSCF.SipSessionManager");
+}
+
+namespace AsteriskSCF
+{
+namespace SipSessionManager
+{
+
+using namespace AsteriskSCF::SIP::Registration::V1;
+
+SipDefaultRegistrarListener::SipDefaultRegistrarListener(const boost::shared_ptr<SipEndpointFactory>& endpointFactory)
+ : mEndpointFactory(endpointFactory) { }
+
+SipDefaultRegistrarListener::~SipDefaultRegistrarListener() { }
+
+void SipDefaultRegistrarListener::contactsAdded(const BindingUpdateSeq& contacts, const Ice::Current&)
+{
+ for (BindingUpdateSeq::const_iterator iter = contacts.begin(); iter != contacts.end(); ++iter)
+ {
+ for (Ice::StringSeq::const_iterator contactIter = iter->contacts.begin();
+ contactIter != iter->contacts.end(); ++contactIter)
+ {
+ lg(Debug) << "Adding new contact " << *contactIter << " to AoR " << iter->aor;
+ }
+ }
+}
+void SipDefaultRegistrarListener::contactsRemoved(const BindingUpdateSeq& contacts, const Ice::Current&)
+{
+ for (BindingUpdateSeq::const_iterator iter = contacts.begin(); iter != contacts.end(); ++iter)
+ {
+ for (Ice::StringSeq::const_iterator contactIter = iter->contacts.begin();
+ contactIter != iter->contacts.end(); ++contactIter)
+ {
+ lg(Debug) << "Removing contact " << *contactIter << " from AoR " << iter->aor;
+ }
+ }
+}
+
+} // namespace SipSessionManager
+} // namespace AsteriskSCF
diff --git a/src/SipRegistrarListener.h b/src/SipRegistrarListener.h
new file mode 100644
index 0000000..973d330
--- /dev/null
+++ b/src/SipRegistrarListener.h
@@ -0,0 +1,41 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#pragma once
+
+#include <AsteriskSCF/SIP/SIPRegistrarIf.h>
+
+#include "SipEndpointFactory.h"
+
+namespace AsteriskSCF
+{
+namespace SipSessionManager
+{
+
+class SipDefaultRegistrarListener : public AsteriskSCF::SIP::Registration::V1::RegistrarListener
+{
+public:
+ SipDefaultRegistrarListener(const boost::shared_ptr<SipEndpointFactory>& endpointFactory);
+ ~SipDefaultRegistrarListener();
+
+ void contactsAdded(const AsteriskSCF::SIP::Registration::V1::BindingUpdateSeq&, const Ice::Current&);
+ void contactsRemoved(const AsteriskSCF::SIP::Registration::V1::BindingUpdateSeq&, const Ice::Current&);
+private:
+ boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
+};
+
+} // namespace SipSessionManager
+} // namespace AsteriskSCF
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index bd711a7..4c7de36 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -44,6 +44,7 @@
#include "SipSession.h"
#include "SipStateReplicator.h"
#include "SipConfiguration.h"
+#include "SipRegistrarListener.h"
using namespace std;
using namespace AsteriskSCF::SipSessionManager;
@@ -54,6 +55,7 @@ using namespace AsteriskSCF::System::Component::V1;
using namespace AsteriskSCF::System::Logging;
using namespace AsteriskSCF::SessionCommunications::V1;
using namespace AsteriskSCF::System::Configuration::V1;
+using namespace AsteriskSCF::SIP::Registration::V1;
namespace
{
@@ -133,11 +135,13 @@ private:
AsteriskSCF::Discovery::SmartProxy<LocatorRegistryPrx> mRoutingServiceLocatorRegistry;
boost::shared_ptr<SipSessionManagerEventPublisher> mEventPublisher;
Routing::V1::EndpointLocatorPtr mEndpointLocator;
+ RegistrarListenerPtr mRegistrarListener;
};
static const string ComponentServiceId("SipChannelComponent");
static const string EndpointLocatorObjectId("SipChannelEndpointLocator");
static const string ReplicaServiceId("SipChannelReplica");
+static const string RegistrarListenerId("SipRegistrarListener");
/**
* This class provides implementation for the ComponentService interface, which
@@ -490,7 +494,13 @@ void SipSessionManager::registerPJSipModules()
}
else if (*i == "Registrar")
{
- mPJSipManager->registerRegistrarModule();
+ RegistrarListenerPrx defaultListener = RegistrarListenerPrx::uncheckedCast(
+ mGlobalAdapter->createDirectProxy(mGlobalAdapter->getCommunicator()->stringToIdentity(RegistrarListenerId)));
+ if (defaultListener == 0)
+ {
+ lg(Warning) << "Adding NULL RegistrarListener as default listener????" << std::endl;
+ }
+ mPJSipManager->registerRegistrarModule(defaultListener);
}
}
lg(Debug) << "Registered PJSIP modules";
@@ -563,6 +573,10 @@ void SipSessionManager::initialize(const string& appName, const Ice::Communicato
mEndpointFactory.reset(new SipEndpointFactory(mGlobalAdapter, mPJSipManager, mServiceLocator, mReplicaService));
lg(Debug) << "Created SIP endpoint factory";
+ mRegistrarListener = new SipDefaultRegistrarListener(mEndpointFactory);
+ mGlobalAdapter->add(mRegistrarListener, mCommunicator->stringToIdentity(RegistrarListenerId));
+ lg(Debug) << "Added default registrar listener to object adapter";
+
// Locate the Routing Service so that we can do routing. This is done here so it can be passed to the configuration service.
locateRoutingService();
commit 591d2f8183dbed4dce5734ae09e5c2d2cb2de8c3
Author: Mark Michelson <mmichelson at digium.com>
Date: Wed Jun 15 10:50:49 2011 -0500
Adjust some debugging messages to be more clear and only print when necessary.
diff --git a/src/PJSipRegistrarModule.cpp b/src/PJSipRegistrarModule.cpp
index e04de12..9d4334a 100644
--- a/src/PJSipRegistrarModule.cpp
+++ b/src/PJSipRegistrarModule.cpp
@@ -59,7 +59,7 @@ BindingHolder::BindingHolder(
{
pj_timer_entry_init(&mEntry, expirationId++, this, registrationExpired);
pj_time_val delay = {expiration, 0};
- lg(Debug) << "Scheduling binding " << mBinding->contact << " for " << expiration << " seconds.";
+ lg(Debug) << "Scheduling binding " << mBinding->contact << " for expiration in " << expiration << " seconds.";
pjsip_endpt_schedule_timer(mEndpoint, &mEntry, &delay);
}
@@ -190,14 +190,20 @@ void RegistrarI::updateBindings(const std::string &aor, BindingHolderSeq&, Bindi
//Let's add in the new bindings, shall we?
if (thingy == mBindings.end())
{
- lg(Debug) << "Adding new bindings";
- mBindings.insert(make_pair(aor, newBindings));
+ if (!newBindings.empty())
+ {
+ lg(Debug) << "Adding new bindings for aor " << aor;
+ mBindings.insert(make_pair(aor, newBindings));
+ }
}
else
{
BindingHolderSeq& currentBindings = thingy->second;
- lg(Debug) << "Adding new bindings";
- currentBindings.insert(currentBindings.end(), newBindings.begin(), newBindings.end());
+ if (!newBindings.empty())
+ {
+ lg(Debug) << "Adding new bindings for aor " << aor;
+ currentBindings.insert(currentBindings.end(), newBindings.begin(), newBindings.end());
+ }
for (BindingHolderSeq::iterator iter = removedBindings.begin(); iter != removedBindings.end(); ++iter)
{
removeBinding(currentBindings, *iter);
commit ae5e868cf90a06e489748299eca32564f248d52b
Author: Mark Michelson <mmichelson at digium.com>
Date: Wed Jun 15 10:48:54 2011 -0500
Remove AoRs from our map if there are no bindings remaining.
This prevented a crash during testing.
diff --git a/src/PJSipRegistrarModule.cpp b/src/PJSipRegistrarModule.cpp
index 9dda376..e04de12 100644
--- a/src/PJSipRegistrarModule.cpp
+++ b/src/PJSipRegistrarModule.cpp
@@ -40,6 +40,11 @@ static void registrationExpired(pj_timer_heap_t *, struct pj_timer_entry *entry)
holder->cancelRegistrationExpiration();
BindingHolderSeq& currentBindings = holder->mRegistrar->getAORBindingHolders(holder->mAOR);
holder->mRegistrar->removeBinding(currentBindings, holder);
+ if (currentBindings.empty())
+ {
+ holder->mRegistrar->removeAOR(holder->mAOR);
+ }
+ delete holder;
}
static int expirationId;
@@ -169,6 +174,11 @@ void RegistrarI::removeBinding(BindingHolderSeq& currentBindings, BindingHolder
currentBindings.erase(std::remove(currentBindings.begin(), currentBindings.end(), holder), currentBindings.end());
}
+void RegistrarI::removeAOR(const std::string& aor)
+{
+ mBindings.erase(aor);
+}
+
void RegistrarI::updateBindings(const std::string &aor, BindingHolderSeq&, BindingHolderSeq& newBindings, BindingHolderSeq& removedBindings)
{
//Best way to do this...
@@ -191,6 +201,11 @@ void RegistrarI::updateBindings(const std::string &aor, BindingHolderSeq&, Bindi
for (BindingHolderSeq::iterator iter = removedBindings.begin(); iter != removedBindings.end(); ++iter)
{
removeBinding(currentBindings, *iter);
+ delete *iter;
+ }
+ if (currentBindings.empty())
+ {
+ removeAOR(aor);
}
}
@@ -447,7 +462,7 @@ pj_bool_t PJSipRegistrarModule::on_rx_request(pjsip_rx_data *rdata)
pjsip_endpt_create_response(tsx->endpt, rdata, 200, NULL, &tdata);
pjsip_tsx_send_msg(tsx, tdata);
- return PJ_FALSE;
+ return PJ_TRUE;
}
pj_bool_t PJSipRegistrarModule::on_rx_response(pjsip_rx_data *)
diff --git a/src/PJSipRegistrarModule.h b/src/PJSipRegistrarModule.h
index dbd3cc1..8c759ce 100644
--- a/src/PJSipRegistrarModule.h
+++ b/src/PJSipRegistrarModule.h
@@ -71,6 +71,7 @@ public:
BindingHolderSeq& getAORBindingHolders(const std::string &aor);
void removeBinding(BindingHolderSeq& currentBindings, BindingHolder *holder);
+ void removeAOR(const std::string& aor);
void updateBindings(
const std::string &aor,
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list