[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Oct 22 14:36:29 CDT 2010


branch "master" has been updated
       via  b1dae4905f0975df445f5cc144bf0476bf69dbf7 (commit)
       via  4c854facff3eed718ab99bc90dfd9eff94138cdf (commit)
      from  c2d438b4c5b08fabbca76b23d0594b757e71fbd8 (commit)

Summary of changes:
 src/BridgeImpl.cpp |   89 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 77 insertions(+), 12 deletions(-)


- Log -----------------------------------------------------------------
commit b1dae4905f0975df445f5cc144bf0476bf69dbf7
Author: Brent Eagles <beagles at digium.com>
Date:   Fri Oct 22 17:04:45 2010 -0230

    Adding a retry around a removeBridge call as well.

diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 46aba16..f1a7036 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -769,17 +769,34 @@ void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::S
     //
     if(toRemove)
     {
-        try
-        {
-            toRemove->getSession()->removeBridge(mSessionListenerPrx);
-        }
-        catch(const AsteriskSCF::SessionCommunications::V1::NotBridged&)
-        {
-            lg(Info) << __FUNCTION__ << ": removeBridge on session being replaced threw a `NotBridged' exception"; 
-        }
-        catch(const Ice::Exception& ex)
+        RetryPolicy policy(5, 500);
+        //
+        // canRetry should never return false since we throw ourselves out of this loop. But 
+        // we'll do it here in case we decide to do something else.
+        //
+        while(policy.canRetry())
         {
-            lg(Info) << __FUNCTION__ << ": removeBridge resulted in : " <<  ex.what();
+            try
+            {
+                toRemove->getSession()->removeBridge(mSessionListenerPrx);
+            }
+            catch(const AsteriskSCF::SessionCommunications::V1::NotBridged&)
+            {
+                lg(Info) << __FUNCTION__ << ": removeBridge on session being replaced threw a `NotBridged' exception"; 
+                break;
+            }
+            catch(const Ice::ConnectionLostException&)
+            {
+                if(!policy.retry())
+                {
+                    throw;
+                }
+            }
+            catch(const Ice::Exception& ex)
+            {
+                lg(Info) << __FUNCTION__ << ": removeBridge resulted in : " <<  ex.what();
+                break;
+            }
         }
     }
 

commit 4c854facff3eed718ab99bc90dfd9eff94138cdf
Author: Brent Eagles <beagles at digium.com>
Date:   Fri Oct 22 17:01:47 2010 -0230

    Adding retry to another setBridge call.

diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 6676e63..46aba16 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -31,6 +31,35 @@ namespace
 {
 Logger &lg = getLoggerFactory().getLogger("AsteriskSCF.BridgeService");
 
+class RetryPolicy
+{
+public:
+    RetryPolicy(size_t maxRetries, size_t intervalInMilliseconds) :
+        mMaxRetries(maxRetries),
+        mRetryInterval(intervalInMilliseconds),
+        mCounter(0)
+    {
+    }
+
+    bool canRetry()
+    {
+        return mCounter < mMaxRetries;
+    }
+
+    bool retry()
+    {
+        lg(Debug) << "Retrying for the " << mCounter + 1 << " time.";
+        IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(mRetryInterval));
+        ++mCounter;
+        return canRetry();
+    }
+
+private:
+    size_t mMaxRetries;
+    size_t mRetryInterval;
+    size_t mCounter;
+};
+
 void checkSessions(const AsteriskSCF::SessionCommunications::V1::SessionSeq& sessions)
 {
     Ice::LongSeq invalidIndexes; 
@@ -687,8 +716,27 @@ void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::S
     {
         try
         {
-            infoSeq.push_back((*i)->setBridge(mPrx, mSessionListenerPrx));
-            newMembers.push_back(new BridgeSession(*i, mSplicer.connect(*i), false));
+            RetryPolicy policy(5, 500);
+            //
+            // canRetry should never return false since we throw ourselves out of this loop. But 
+            // we'll do it here in case we decide to do something else.
+            //
+            while(policy.canRetry())
+            {
+                try
+                {
+                    infoSeq.push_back((*i)->setBridge(mPrx, mSessionListenerPrx));
+                    newMembers.push_back(new BridgeSession(*i, mSplicer.connect(*i), false));
+                    break;
+                }
+                catch(const Ice::ConnectionLostException& ex)
+                {
+                    if(!policy.retry())
+                    {
+                        throw;
+                    }
+                }
+            }
         }
         catch(const Ice::Exception& ex)
         {

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list