[asterisk-addons-commits] trunk r206 - /trunk/asterisk-ooh323c/src/chan_h323.c

asterisk-addons-commits at lists.digium.com asterisk-addons-commits at lists.digium.com
Tue Apr 11 07:22:27 MST 2006


Author: objsys
Date: Tue Apr 11 09:22:26 2006
New Revision: 206

URL: http://svn.digium.com/view/asterisk-addons?rev=206&view=rev
Log:
contains 3 bug fixes

Modified:
    trunk/asterisk-ooh323c/src/chan_h323.c

Modified: trunk/asterisk-ooh323c/src/chan_h323.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/asterisk-ooh323c/src/chan_h323.c?rev=206&r1=205&r2=206&view=diff
==============================================================================
--- trunk/asterisk-ooh323c/src/chan_h323.c (original)
+++ trunk/asterisk-ooh323c/src/chan_h323.c Tue Apr 11 09:22:26 2006
@@ -403,7 +403,7 @@
    if (!pvt->rtp) 
    {
       ast_log(LOG_WARNING, "Unable to create RTP session: %s\n", 
-                                                            strerror(errno));
+              strerror(errno));
       ast_mutex_unlock(&pvt->lock);
       ast_mutex_destroy(&pvt->lock);
       free(pvt);
@@ -790,8 +790,7 @@
       if(gH323Debug)
          ast_verbose("    hanging %s\n", p->username);
 
-      if(!ast_test_flag(p, H323_ALREADYGONE))
-      {
+      if(!ast_test_flag(p, H323_ALREADYGONE)) {
          ast_mutex_lock(&ooh323c_cmd_lock);
          ooHangCall(p->callToken, 
              ooh323_convert_hangupcause_asteriskToH323(p->owner->hangupcause));
@@ -809,16 +808,16 @@
          p->owner = NULL;
       }
 
-     ast_mutex_unlock(&p->lock);
-     ast_mutex_lock(&usecnt_lock);
-     usecnt--;
-     ast_mutex_unlock(&usecnt_lock);
-   
-     /* Notify the module monitors that use count for resource has changed*/
-     ast_update_use_count();
+      ast_mutex_unlock(&p->lock);
+      ast_mutex_lock(&usecnt_lock);
+      usecnt--;
+      ast_mutex_unlock(&usecnt_lock);
+
+      /* Notify the module monitors that use count for resource has changed */
+      ast_update_use_count();
      
    }
-   else{
+   else {
       ast_log(LOG_ERROR, "No call to hangup\n" );
       return -1;
    }
@@ -1063,7 +1062,7 @@
       }
       ast_mutex_unlock(&p->lock);
    }
-   else{
+   else {
       if (!p->owner) {
          ast_mutex_unlock(&p->lock);
          ast_log(LOG_ERROR, "Channel has no owner\n");
@@ -1096,9 +1095,12 @@
 
    ast_log(LOG_DEBUG, "Received Digit: %c\n", digit);
    p = find_call(call);
-   if(!p)
-   {
+   if(!p) {
       ast_log(LOG_ERROR, "Failed to find a matching call.\n");
+      return -1;
+   }
+   if(!p->owner) {
+      ast_log(LOG_ERROR, "Channel has no owner\n");
       return -1;
    }
    ast_mutex_lock(&p->lock);
@@ -1383,33 +1385,35 @@
 int onCallCleared(ooCallData *call)
 {
    struct ooh323_pvt *p = NULL;
-   struct ast_channel *c=NULL;
+   int ownerLock = 0;
 
    if(gH323Debug)
       ast_verbose("---   onCallCleared %s \n", call->callToken);
 
    p = find_call(call); 
-   if (!p) {
-      return 0;
-   }
+   if (!p) { return 0; }
    ast_mutex_lock(&p->lock);
   
-   if(p->owner) {
-      while(ast_mutex_trylock(&p->owner->lock))
-      {
+   while(p->owner) {
+      if(ast_mutex_trylock(&p->owner->lock)) {
+         ooTrace(OOTRCLVLINFO, "Failed to grab lock, trying again\n");
          ast_log(LOG_DEBUG,"Failed to grab lock, trying again\n");
          ast_mutex_unlock(&p->lock);
          usleep(1);
          ast_mutex_lock(&p->lock);
-      }    
-
-      c = p->owner;
-
-      if(!ast_test_flag(p, H323_ALREADYGONE))
-      { /* NOTE Channel is not detached yet */
+      }
+      else {
+         ownerLock = 1; break;
+      }
+   }
+
+   if(ownerLock) {
+      if(!ast_test_flag(p, H323_ALREADYGONE)) { 
+
+         /* NOTE: Channel is not detached yet */
          ast_set_flag(p, H323_ALREADYGONE);
-         p->owner->hangupcause = ooh323_convert_hangupcause_h323ToAsterisk(
-                                                          call->callEndReason);
+         p->owner->hangupcause = 
+            ooh323_convert_hangupcause_h323ToAsterisk(call->callEndReason);
          p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
          ast_mutex_unlock(&p->owner->lock);
          ast_queue_hangup(p->owner);
@@ -2539,10 +2543,9 @@
 
 int ooh323_destroy(struct ooh323_pvt *p)
 {
-  /* NOTE: Assumes iflock already acquired */
+   /* NOTE: Assumes iflock already acquired */
    struct ooh323_pvt *prev=NULL,*cur = NULL;
 
-   cur = iflist;
 
    if(gH323Debug)
    {
@@ -2552,10 +2555,11 @@
          ast_verbose(" Destroying %s\n", p->username);
    }
 
+   cur = iflist;
    while(cur)
    {
       if(cur == p) { break; }
-      prev=cur;
+      prev = cur;
       cur = cur->next;
    }
 
@@ -2583,9 +2587,9 @@
          free(cur->callerid_num);
 
 
-       if (cur->rtp)
-          ast_rtp_destroy(cur->rtp);
-
+      if (cur->rtp)
+         ast_rtp_destroy(cur->rtp);
+	
       /* Unlink us from the owner if we have one */
       if (cur->owner) {
          ast_mutex_lock(&cur->owner->lock);
@@ -2655,7 +2659,7 @@
   
 int unload_module()
 {
-   struct ooh323_pvt *p, *pl;
+   struct ooh323_pvt *p;
    struct ooAliases *cur=NULL, *prev=NULL;
 
    if(gH323Debug) {
@@ -2724,13 +2728,15 @@
       ast_verbose("  unload_module - freeing up memory used by interfaces\n");
    }
    if (!ast_mutex_lock(&iflock)) {
+      struct ooh323_pvt *pl;
+
       /* Destroy all the interfaces and free their memory */
       p = iflist;
       while(p) {
          pl = p;
          p = p->next;
          /* Free associated memory */
-         ooh323_destroy(p);
+         ooh323_destroy(pl);
       }
       iflist = NULL;
       ast_mutex_unlock(&iflock);



More information about the asterisk-addons-commits mailing list