[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "retry_deux" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Wed Jan 18 16:38:44 CST 2012
branch "retry_deux" has been updated
via 0d7330f79f2e697442a5b9498f71d84b39a2bacf (commit)
from d8ee2c4f6f96736c65d6d0a3ba5534f3e3ac3ac1 (commit)
Summary of changes:
src/PJSIPSessionModule.cpp | 41 +++++++++++++++++++----------------------
src/PJSIPSessionModule.h | 12 ++++++++++++
2 files changed, 31 insertions(+), 22 deletions(-)
- Log -----------------------------------------------------------------
commit 0d7330f79f2e697442a5b9498f71d84b39a2bacf
Author: Ken Hunt <ken.hunt at digium.com>
Date: Wed Jan 18 16:38:53 2012 -0600
Incorporating review feedback.
diff --git a/src/PJSIPSessionModule.cpp b/src/PJSIPSessionModule.cpp
index 971e421..754502e 100644
--- a/src/PJSIPSessionModule.cpp
+++ b/src/PJSIPSessionModule.cpp
@@ -480,8 +480,9 @@ protected:
mSession->setSelfAsCaller();
SuspendableWorkListenerPtr listener = 0;
- mAmiCallback = new SIPAMICallback(listener, mSession, this, false, true);
- invokeOperation();
+ SIPAMICallbackPtr amiCallback = new SIPAMICallback(listener, mSession, this, false, true);
+ SIPAMICallbackCookiePtr cookie = new SIPAMICallbackCookie(amiCallback);
+ invokeOperation(cookie);
}
}
catch (const Ice::CommunicatorDestroyedException &)
@@ -499,10 +500,15 @@ protected:
return Complete;
}
- void invokeOperation()
+ /**
+ * Invoke the operation.
+ * @param cookie The cookie contains the SIPAMICallback object. Passed into the AMI operation so
+ * that retry operations have access to the callback object.
+ */
+ void invokeOperation(const SIPAMICallbackCookiePtr& cookie)
{
- Ice::CallbackPtr d = Ice::newCallback(mAmiCallback, &SIPAMICallback::callback);
- mSessionRouter->begin_routeSession(mOperationId, mSession->getSessionProxy(), mDestination, 0, mCallerID, mRedirections, d);
+ Ice::CallbackPtr d = Ice::newCallback(cookie->getSIPAMICallback(), &SIPAMICallback::callback);
+ mSessionRouter->begin_routeSession(mOperationId, mSession->getSessionProxy(), mDestination, 0, mCallerID, mRedirections, d, cookie);
}
SuspendableWorkResult calledBack(const Ice::AsyncResultPtr& asyncResult)
@@ -511,11 +517,6 @@ protected:
try
{
router->end_routeSession(asyncResult);
-
- // If no exception, we'll get here and the callback object is no longer needed.
- // Delete cached smart pointer to avoid memory leak, as it holds a reference to
- // this object.
- mAmiCallback = 0;
}
catch (const Ice::ConnectionLostException &cle)
{
@@ -523,20 +524,17 @@ protected:
// This will block the WorkQueue's thread, but it's highly likely
// that the failover effects most of the other enqueued operations
// anyway.
- if(mRetryPolicy.canRetry())
+ if(mRetryPolicy.retry())
{
lg(Warning) << "SessionCreationOperation: Retrying routeSession operation.";
- if(!mRetryPolicy.retry())
- {
- lg(Error) << "SessionCreationOperation: ConnectionLostException routing session failed " << mRetryPolicy.getMaxRetries() << " retries." ;
- endSession(500);
- }
- else
- {
- // Retry the operation.
- invokeOperation();
- }
+ // Retry the operation.
+ invokeOperation(SIPAMICallbackCookiePtr::dynamicCast(asyncResult->getCookie()));
+ }
+ else
+ {
+ lg(Error) << "SessionCreationOperation: ConnectionLostException routing session failed " << mRetryPolicy.getMaxRetries() << " retries." ;
+ endSession(500);
}
}
catch (const DestinationNotFoundException &)
@@ -575,7 +573,6 @@ private:
RedirectionsPtr mRedirections;
RetryPolicy mRetryPolicy;
std::string mOperationId;
- SIPAMICallbackPtr mAmiCallback;
};
bool PJSIPSessionModule::getPrivacy(pjsip_rx_data *rdata)
diff --git a/src/PJSIPSessionModule.h b/src/PJSIPSessionModule.h
index 7a6cbec..a6d2189 100644
--- a/src/PJSIPSessionModule.h
+++ b/src/PJSIPSessionModule.h
@@ -372,5 +372,17 @@ private:
typedef IceUtil::Handle<SIPAMICallback> SIPAMICallbackPtr;
+class SIPAMICallbackCookie : public Ice::LocalObject
+{
+public:
+ SIPAMICallbackCookie(const SIPAMICallbackPtr& c) : mCallbackPtr(c) {}
+ SIPAMICallbackPtr getSIPAMICallback() { return mCallbackPtr; }
+
+private:
+ SIPAMICallbackPtr mCallbackPtr;
+};
+
+typedef IceUtil::Handle<SIPAMICallbackCookie> SIPAMICallbackCookiePtr;
+
}; //end namespace SIPSessionManager
}; //end namespace AsteriskSCF
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list