[asterisk-commits] may: branch 1.8 r330827 - /branches/1.8/addons/ooh323c/src/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 4 14:37:20 CDT 2011


Author: may
Date: Thu Aug  4 14:37:16 2011
New Revision: 330827

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=330827
Log:
change gk client behaivour on rrq/grq failures to setup timers
and next tries after timeout instead of complete failure in the ooh323
stack

Modified:
    branches/1.8/addons/ooh323c/src/ooCmdChannel.c
    branches/1.8/addons/ooh323c/src/ooGkClient.c

Modified: branches/1.8/addons/ooh323c/src/ooCmdChannel.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/addons/ooh323c/src/ooCmdChannel.c?view=diff&rev=330827&r1=330826&r2=330827
==============================================================================
--- branches/1.8/addons/ooh323c/src/ooCmdChannel.c (original)
+++ branches/1.8/addons/ooh323c/src/ooCmdChannel.c Thu Aug  4 14:37:16 2011
@@ -171,7 +171,7 @@
       if(cmd.type == OO_CMD_NOOP)
          continue;
 
-      if(gH323ep.gkClient && gH323ep.gkClient->state != GkClientRegistered)
+      if(gH323ep.gkClient && gH323ep.gkClient->state != GkClientRegistered && cmd.type != OO_CMD_STOPMONITOR)
       {
          OOTRACEINFO1("Ignoring stack command as Gk Client is not registered"
                       " yet\n");

Modified: branches/1.8/addons/ooh323c/src/ooGkClient.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/addons/ooh323c/src/ooGkClient.c?view=diff&rev=330827&r1=330826&r2=330827
==============================================================================
--- branches/1.8/addons/ooh323c/src/ooGkClient.c (original)
+++ branches/1.8/addons/ooh323c/src/ooGkClient.c Thu Aug  4 14:37:16 2011
@@ -2569,7 +2569,43 @@
    }
    memFreePtr(&pGkClient->ctxt, cbData);
    OOTRACEERR1("Error:Failed to register with gatekeeper\n");
-   pGkClient->state = GkClientGkErr;
+   pGkClient->state = GkClientUnregistered;
+
+
+/* Create timer to re-register after default timeout */
+/* network failure is one of cases here */
+
+   ast_mutex_lock(&pGkClient->Lock);
+
+   cbData = (ooGkClientTimerCb*) memAlloc
+				(&pGkClient->ctxt, sizeof(ooGkClientTimerCb));
+   if(!cbData)
+   {
+      OOTRACEERR1("Error:Failed to allocate memory to RRQ timer callback\n");
+      pGkClient->state = GkClientFailed;
+      ast_mutex_unlock(&pGkClient->Lock);
+      return OO_FAILED;
+   }
+
+
+   cbData->timerType = OO_RRQ_TIMER;
+   cbData->pGkClient = pGkClient;
+   if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList,
+                     &ooGkClientRRQTimerExpired, pGkClient->regTimeout,
+                     cbData, FALSE))
+   {
+      OOTRACEERR1("Error:Unable to create GRQ timer.\n ");
+      memFreePtr(&pGkClient->ctxt, cbData);
+      pGkClient->state = GkClientFailed;
+      ast_mutex_unlock(&pGkClient->Lock);
+      return OO_FAILED;
+   }
+
+/* clear rrq count for re-register after regTimeout */
+   pGkClient->rrqRetries = 0;
+
+   ast_mutex_unlock(&pGkClient->Lock);
+
    return OO_FAILED;
 }
 
@@ -2597,7 +2633,37 @@
    }
 
    OOTRACEERR1("Error:Gatekeeper could not be found\n");
-   pGkClient->state = GkClientGkErr;
+   pGkClient->state = GkClientUnregistered;
+/* setup timer to re-send grq after timeout */
+
+   ast_mutex_lock(&pGkClient->Lock);
+   cbData = (ooGkClientTimerCb*) memAlloc
+                               (&pGkClient->ctxt, sizeof(ooGkClientTimerCb));
+   if(!cbData)
+   {
+      OOTRACEERR1("Error:Failed to allocate memory to GRQ timer callback\n");
+      pGkClient->state = GkClientFailed;
+      ast_mutex_unlock(&pGkClient->Lock);
+      return OO_FAILED;
+   }
+   cbData->timerType = OO_GRQ_TIMER;
+   cbData->pGkClient = pGkClient;
+   if(!ooTimerCreate(&pGkClient->ctxt, &pGkClient->timerList,
+                     &ooGkClientGRQTimerExpired, pGkClient->grqTimeout,
+                     cbData, FALSE))
+   {
+      OOTRACEERR1("Error:Unable to create GRQ timer.\n ");
+      memFreePtr(&pGkClient->ctxt, cbData);
+      pGkClient->state = GkClientFailed;
+      ast_mutex_unlock(&pGkClient->Lock);
+      return OO_FAILED;
+   }
+ 
+/* clear grq counter */
+
+   pGkClient->grqRetries = 0;
+   ast_mutex_unlock(&pGkClient->Lock);
+
    return OO_FAILED;
 }
    




More information about the asterisk-commits mailing list