[asterisk-commits] rmudgett: trunk r291508 - in /trunk: ./ channels/chan_misdn.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Oct 13 14:06:59 CDT 2010
Author: rmudgett
Date: Wed Oct 13 14:06:55 2010
New Revision: 291508
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=291508
Log:
Merged revisions 291507 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
................
r291507 | rmudgett | 2010-10-13 14:01:48 -0500 (Wed, 13 Oct 2010) | 18 lines
Merged revision 291504 from
https://origsvn.digium.com/svn/asterisk/be/branches/C.3-bier
..........
r291504 | rmudgett | 2010-10-13 13:30:21 -0500 (Wed, 13 Oct 2010) | 11 lines
Hold off ast_hangup() from destroying the ast_channel.
Must get the ast_channel lock before proceeding with release_chan() and
release_chan_early() to hold off ast_hangup() from destroying the
ast_channel.
Missed this change for -r291468.
JIRA ABE-2598
JIRA SWP-2317
..........
................
Modified:
trunk/ (props changed)
trunk/channels/chan_misdn.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: trunk/channels/chan_misdn.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_misdn.c?view=diff&rev=291508&r1=291507&r2=291508
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Wed Oct 13 14:06:55 2010
@@ -8332,16 +8332,42 @@
{
struct ast_channel *ast;
+ chan_misdn_log(5, bc->port, "release_chan: bc with pid:%d l3id: %x\n", bc->pid, bc->l3_id);
+
ast_mutex_lock(&release_lock);
+ for (;;) {
+ ast = ch->ast;
+ if (!ast || !ast_channel_trylock(ast)) {
+ break;
+ }
+ DEADLOCK_AVOIDANCE(&release_lock);
+ }
if (!cl_dequeue_chan(ch)) {
/* Someone already released it. */
+ if (ast) {
+ ast_channel_unlock(ast);
+ }
ast_mutex_unlock(&release_lock);
return;
}
ch->state = MISDN_CLEANING;
- ast = ch->ast;
ch->ast = NULL;
- ast_mutex_unlock(&release_lock);
+ if (ast) {
+ MISDN_ASTERISK_TECH_PVT(ast) = NULL;
+ chan_misdn_log(1, bc->port,
+ "* RELEASING CHANNEL pid:%d context:%s dialed:%s caller:\"%s\" <%s>\n",
+ bc->pid,
+ ast->context,
+ ast->exten,
+ S_COR(ast->caller.id.name.valid, ast->caller.id.name.str, ""),
+ S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, ""));
+
+ if (ast->_state != AST_STATE_RESERVED) {
+ chan_misdn_log(3, bc->port, " --> Setting AST State to down\n");
+ ast_setstate(ast, AST_STATE_DOWN);
+ }
+ ast_channel_unlock(ast);
+ }
#if defined(AST_MISDN_ENHANCEMENTS)
if (ch->peer) {
@@ -8354,8 +8380,6 @@
ast_dsp_free(ch->dsp);
ch->dsp = NULL;
}
-
- chan_misdn_log(5, bc->port, "release_chan: bc with pid:%d l3id: %x\n", bc->pid, bc->l3_id);
/* releasing jitterbuffer */
if (ch->jb) {
@@ -8384,27 +8408,9 @@
close(ch->pipe[0]);
close(ch->pipe[1]);
- if (ast) {
- ast_channel_lock(ast);
- MISDN_ASTERISK_TECH_PVT(ast) = NULL;
- chan_misdn_log(1, bc->port,
- "* RELEASING CHANNEL pid:%d context:%s dialed:%s caller:\"%s\" <%s>\n",
- bc->pid,
- ast->context,
- ast->exten,
- (ast->caller.id.name.valid && ast->caller.id.name.str)
- ? ast->caller.id.name.str : "",
- (ast->caller.id.number.valid && ast->caller.id.number.str)
- ? ast->caller.id.number.str : "");
-
- if (ast->_state != AST_STATE_RESERVED) {
- chan_misdn_log(3, bc->port, " --> Setting AST State to down\n");
- ast_setstate(ast, AST_STATE_DOWN);
- }
- ast_channel_unlock(ast);
- }
-
ast_free(ch);
+
+ ast_mutex_unlock(&release_lock);
}
/*!
@@ -8422,15 +8428,30 @@
struct ast_channel *ast;
ast_mutex_lock(&release_lock);
+ for (;;) {
+ ast = ch->ast;
+ if (!ast || !ast_channel_trylock(ast)) {
+ break;
+ }
+ DEADLOCK_AVOIDANCE(&release_lock);
+ }
if (!cl_dequeue_chan(ch)) {
/* Someone already released it. */
+ if (ast) {
+ ast_channel_unlock(ast);
+ }
ast_mutex_unlock(&release_lock);
return;
}
ch->state = MISDN_CLEANING;
- ast = ch->ast;
ch->ast = NULL;
- ast_mutex_unlock(&release_lock);
+ if (ast) {
+ MISDN_ASTERISK_TECH_PVT(ast) = NULL;
+ if (ast->_state != AST_STATE_RESERVED) {
+ ast_setstate(ast, AST_STATE_DOWN);
+ }
+ ast_channel_unlock(ast);
+ }
#if defined(AST_MISDN_ENHANCEMENTS)
if (ch->peer) {
@@ -8469,16 +8490,9 @@
close(ch->pipe[0]);
close(ch->pipe[1]);
- if (ast) {
- ast_channel_lock(ast);
- MISDN_ASTERISK_TECH_PVT(ast) = NULL;
- if (ast->_state != AST_STATE_RESERVED) {
- ast_setstate(ast, AST_STATE_DOWN);
- }
- ast_channel_unlock(ast);
- }
-
ast_free(ch);
+
+ ast_mutex_unlock(&release_lock);
}
/*!
More information about the asterisk-commits
mailing list