[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
Tue Jan 17 21:02:34 CST 2012


branch "retry_deux" has been updated
       via  d8ee2c4f6f96736c65d6d0a3ba5534f3e3ac3ac1 (commit)
      from  df5d82f9460d3d582f89dbd1c31c770d7291b4fa (commit)

Summary of changes:
 src/PJSIPSessionModule.cpp |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)


- Log -----------------------------------------------------------------
commit d8ee2c4f6f96736c65d6d0a3ba5534f3e3ac3ac1
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Jan 17 21:02:10 2012 -0600

    Corrected bonehead mistakes made in a rush.

diff --git a/src/PJSIPSessionModule.cpp b/src/PJSIPSessionModule.cpp
index 9fcbfcb..971e421 100644
--- a/src/PJSIPSessionModule.cpp
+++ b/src/PJSIPSessionModule.cpp
@@ -386,7 +386,8 @@ public:
         mReplacedDialog(replacedDialog),
         mDestination(destination),
         mCallerID(callerID),
-        mRedirections(redirections) { }
+        mRedirections(redirections),
+        mRetryPolicy(5, 500) { }
 
 protected:
     SuspendableWorkResult initial(const SuspendableWorkListenerPtr&)
@@ -510,6 +511,11 @@ 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)
         {
@@ -517,14 +523,13 @@ protected:
             // This will block the WorkQueue's thread, but it's highly likely
             // that the failover effects most of the other enqueued operations 
             // anyway. 
-            RetryPolicy retryPolicy(5,500);
-            while(retryPolicy.canRetry())
+            if(mRetryPolicy.canRetry())
             {
                 lg(Warning) << "SessionCreationOperation: Retrying routeSession operation.";
 
-                if(!retryPolicy.retry())
+                if(!mRetryPolicy.retry())
                 {
-                    lg(Error) << "SessionCreationOperation: ConnectionLostException routing session failed "  << retryPolicy.getMaxRetries() << " retries." ;
+                    lg(Error) << "SessionCreationOperation: ConnectionLostException routing session failed "  << mRetryPolicy.getMaxRetries() << " retries." ;
                     endSession(500);
                 }
                 else
@@ -568,6 +573,7 @@ private:
     SIPSessionPtr mSession;
     CallerPtr mCallerID;
     RedirectionsPtr mRedirections;
+    RetryPolicy mRetryPolicy;
     std::string mOperationId;
     SIPAMICallbackPtr mAmiCallback;
 };

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list