[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
Mon Jun 20 10:35:34 CDT 2011
branch "registrar" has been updated
via cfa23a3f19760c5266a9f4be0ad9302c977bfe8a (commit)
from a6bfcd47c9f662ac6dd4a2318d96579737a12837 (commit)
Summary of changes:
src/PJSipRegistrarModule.h | 29 ++++++++++++-----------
src/SipStateReplicatorListener.cpp | 44 ++++++++++++++++++++++-------------
2 files changed, 43 insertions(+), 30 deletions(-)
- Log -----------------------------------------------------------------
commit cfa23a3f19760c5266a9f4be0ad9302c977bfe8a
Author: Mark Michelson <mmichelson at digium.com>
Date: Mon Jun 20 10:35:30 2011 -0500
Fix memory leak in state replicator listener.
diff --git a/src/PJSipRegistrarModule.h b/src/PJSipRegistrarModule.h
index 885b9ad..e56a321 100644
--- a/src/PJSipRegistrarModule.h
+++ b/src/PJSipRegistrarModule.h
@@ -83,6 +83,21 @@ public:
pj_status_t on_tx_response(pjsip_tx_data *tdata);
void on_tsx_state(pjsip_transaction *tsx, pjsip_event *event);
RegistrarIPtr getRegistrar();
+
+ /**
+ * Replicate state of bindings currently held by this registrar.
+ *
+ * State replication will send at most three RPCs.
+ * The first will contain any new bindings added by a REGISTER
+ * The next will contain any updates to existing bindings from a REGISTER
+ * The final will contain any bindings removed from a REGISTER
+ */
+ void replicateState(
+ const std::string &aor,
+ BindingWrapperSeq& existingBindings,
+ BindingWrapperSeq& newBindings,
+ BindingWrapperSeq& removedBindings);
+
private:
/**
* Extract the AoR from the To header of a REGISTER request
@@ -109,20 +124,6 @@ private:
BindingWrapper *createNewBinding(pjsip_contact_hdr *contact,
const std::string& callID, int cSeq, int expiration, const std::string& aor);
- /**
- * Replicate state of bindings currently held by this registrar.
- *
- * State replication will send at most three RPCs.
- * The first will contain any new bindings added by a REGISTER
- * The next will contain any updates to existing bindings from a REGISTER
- * The final will contain any bindings removed from a REGISTER
- */
- void replicateState(
- const std::string &aor,
- BindingWrapperSeq& existingBindings,
- BindingWrapperSeq& newBindings,
- BindingWrapperSeq& removedBindings);
-
pjsip_endpoint *mEndpoint;
RegistrarIPtr mRegistrar;
AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::SIP::V1::SipStateReplicatorPrx> mStateReplicator;
diff --git a/src/SipStateReplicatorListener.cpp b/src/SipStateReplicatorListener.cpp
index d2bcdc0..61df232 100644
--- a/src/SipStateReplicatorListener.cpp
+++ b/src/SipStateReplicatorListener.cpp
@@ -86,6 +86,17 @@ public:
return wrapper;
}
+ struct BindingFinder
+ {
+ BindingFinder(const BindingPtr& binding)
+ : mBinding(binding) { }
+ bool operator()(BindingWrapper *wrapper)
+ {
+ return *wrapper == mBinding;
+ }
+ BindingPtr mBinding;
+ };
+
void removeRegistrationState(
const PJSipRegistrarModulePtr& regModule,
const SipRegistrarStateItemPtr& regItem)
@@ -93,17 +104,29 @@ public:
for (BindingDict::iterator dictIter = regItem->bindings.begin();
dictIter != regItem->bindings.end(); ++dictIter)
{
-
BindingSeq bindings = dictIter->second;
+
+ BindingWrapperSeq& existingBindings =
+ regModule->getRegistrar()->getAORBindingWrappers(dictIter->first);
+
BindingWrapperSeq emptySeq;
- BindingWrapperSeq wrapperSeq;
+ BindingWrapperSeq toRemove;
+
for (BindingSeq::iterator seqIter = bindings.begin();
seqIter != bindings.end(); ++seqIter)
{
- BindingWrapper *wrapper = createBindingWrapper(dictIter->first, *seqIter, regModule);
- wrapperSeq.push_back(wrapper);
+ BindingWrapperSeq::iterator wrapperToRemove =
+ std::find_if(existingBindings.begin(), existingBindings.end(), BindingFinder(*seqIter));
+
+ if (wrapperToRemove == existingBindings.end())
+ {
+ toRemove.push_back(*wrapperToRemove);
+ }
+ //It's possible that we're being asked to remove a binding
+ //that we've already expired and removed. No biggie. Just
+ //keep going.
}
- regModule->getRegistrar()->updateBindings(dictIter->first, emptySeq, wrapperSeq);
+ regModule->getRegistrar()->updateBindings(dictIter->first, emptySeq, toRemove);
}
}
@@ -147,17 +170,6 @@ public:
}
}
- struct BindingFinder
- {
- BindingFinder(const BindingPtr& binding)
- : mBinding(binding) { }
- bool operator()(BindingWrapper *wrapper)
- {
- return *wrapper == mBinding;
- }
- BindingPtr mBinding;
- };
-
void setExistingRegistrationState(const PJSipRegistrarModulePtr& regModule, const SipRegistrarStateItemPtr& regItem)
{
for (BindingDict::iterator dictIter = regItem->bindings.begin();
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list