[svn-commits] trunk - r185 /trunk/asterisk-ooh323c/src/chan_h323.c
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Fri Dec 9 12:45:48 CST 2005
Author: objsys
Date: Fri Dec 9 12:45:47 2005
New Revision: 185
URL: http://svn.digium.com/view/asterisk-addons?rev=185&view=rev
Log:
Fixed 4 deadlocks
conditions in onAlerting, onReceivedDigit and onCallExstablished fun
tions
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=185&r1=184&r2=185&view=diff
==============================================================================
--- trunk/asterisk-ooh323c/src/chan_h323.c (original)
+++ trunk/asterisk-ooh323c/src/chan_h323.c Fri Dec 9 12:45:47 2005
@@ -16,8 +16,6 @@
#include "chan_h323.h"
-
-
/* Defaults */
@@ -1054,18 +1052,22 @@
ast_log(LOG_ERROR, "Could not create ast_channel\n");
return -1;
}
-
- }else{
+ ast_mutex_unlock(&p->lock);
+ }
+ else{
if (!p->owner) {
ast_mutex_unlock(&p->lock);
ast_log(LOG_ERROR, "Channel has no owner\n");
return 0;
}
c = p->owner;
+ ast_mutex_unlock(&p->lock);
+ ast_mutex_lock(&c->lock);
ast_setstate(c, AST_STATE_RINGING);
+ ast_mutex_unlock(&c->lock);
ast_queue_control(c, AST_CONTROL_RINGING);
- }
- ast_mutex_unlock(&p->lock);
+ }
+
if(gH323Debug)
ast_verbose("+++ onAlerting %s\n", call->callToken);
@@ -1100,8 +1102,8 @@
f.data = NULL;
f.mallocd = 0;
f.src = "SEND_DIGIT";
+ ast_mutex_unlock(&p->lock);
res = ast_queue_frame(p->owner, &f);
- ast_mutex_unlock(&p->lock);
return res;
}
@@ -1331,8 +1333,7 @@
ast_verbose("--- onCallEstablished %s\n", call->callToken);
p = find_call(call);
- if(!p)
- {
+ if(!p) {
ast_log(LOG_ERROR, "Failed to find a matching call.\n");
return -1;
}
@@ -1343,15 +1344,24 @@
return -1;
}
+ while(ast_mutex_trylock(&p->owner->lock))
+ {
+ ast_log(LOG_DEBUG,"Failed to grab lock, trying again\n");
+ ast_mutex_unlock(&p->lock);
+ usleep(1);
+ ast_mutex_lock(&p->lock);
+ }
if(p->owner->_state != AST_STATE_UP)
{
- ast_mutex_lock(&p->owner->lock);
ast_setstate(p->owner, AST_STATE_UP);
- ast_mutex_unlock(&p->owner->lock);
- }
- if(ast_test_flag(p, H323_OUTGOING))
- ast_queue_control(p->owner, AST_CONTROL_ANSWER);
- ast_mutex_unlock(&p->lock);
+ }
+ ast_mutex_unlock(&p->owner->lock);
+ if(ast_test_flag(p, H323_OUTGOING)) {
+ struct ast_channel* c = p->owner;
+ ast_mutex_unlock(&p->lock);
+ ast_queue_control(c, AST_CONTROL_ANSWER);
+ }
+ else { ast_mutex_unlock(&p->lock); }
if(gH323Debug)
ast_verbose("+++ onCallEstablished %s\n", call->callToken);
@@ -2433,20 +2443,17 @@
}
/* Check for interfaces needing to be killed */
ast_mutex_lock(&iflock);
- int b_restartsearch = 1;
- while(b_restartsearch) {
- time(&t);
- h323 = iflist;
- b_restartsearch = 0;
- while(h323) {
- /*TODO: Need to add rtptimeout keepalive support */
- if(ast_test_flag(h323, H323_NEEDDESTROY)) {
- ooh323_destroy(h323);
- b_restartsearch = 1;
- break;
- }
- h323 = h323->next;
+ struct ooh323_pvt *h323_next;
+ time(&t);
+ h323 = iflist;
+ while(h323) {
+ h323_next = h323->next;
+
+ /*TODO: Need to add rtptimeout keepalive support */
+ if(ast_test_flag(h323, H323_NEEDDESTROY)) {
+ ooh323_destroy (h323);
}
+ h323 = h323_next;
}
ast_mutex_unlock(&iflock);
pthread_testcancel();
@@ -3078,7 +3085,3 @@
}
-
-
-
-
More information about the svn-commits
mailing list