[asterisk-commits] wedhorn: trunk r404307 - in /trunk: ./ channels/chan_skinny.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Dec 18 20:59:56 CST 2013
Author: wedhorn
Date: Wed Dec 18 20:59:52 2013
New Revision: 404307
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404307
Log:
Fixup some skinny bugs causing Fracks and ao2 cleanup issues.
Moved channel locking into setsubstate so that a process can complete
working on a sub before another starts changing it. The existing code
was causing some Fracks with schedule deletion.
Removed multiple rtp cleanup. Now only cleansup up once, fixing ao2
object cleanup issues.
........
Merged revisions 404306 from http://svn.asterisk.org/svn/asterisk/branches/12
Modified:
trunk/ (props changed)
trunk/channels/chan_skinny.c
Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Wed Dec 18 20:59:52 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403778,403781-404006,404027,404029,404042,404046,404048,404050,404099,404137,404184,404204,404237,404261,404263,404279,404292,404294
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-403290,403292-403778,403781-404006,404027,404029,404042,404046,404048,404050,404099,404137,404184,404204,404237,404261,404263,404279,404292,404294,404306
Modified: trunk/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_skinny.c?view=diff&rev=404307&r1=404306&r2=404307
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Wed Dec 18 20:59:52 2013
@@ -2006,6 +2006,20 @@
return list;
}
+static void skinny_locksub(struct skinny_subchannel *sub)
+{
+ if (sub && sub->owner) {
+ ast_channel_lock(sub->owner);
+ }
+}
+
+static void skinny_unlocksub(struct skinny_subchannel *sub)
+{
+ if (sub && sub->owner) {
+ ast_channel_unlock(sub->owner);
+ }
+}
+
static int skinny_sched_del(int sched_id, struct skinny_subchannel *sub)
{
SKINNY_DEBUG(DEBUG_SUB, 3, "Sub %d - Deleting SCHED %d\n",
@@ -4921,8 +4935,10 @@
static int skinny_autoanswer_cb(const void *data)
{
struct skinny_subchannel *sub = (struct skinny_subchannel *)data;
+ skinny_locksub(sub);
sub->aa_sched = 0;
setsubstate(sub, SKINNY_CONNECTED);
+ skinny_unlocksub(sub);
return 0;
}
@@ -4969,6 +4985,7 @@
return -1;
}
+ skinny_locksub(sub);
AST_LIST_TRAVERSE(ast_channel_varshead(ast), current, entries) {
if (!(strcmp(ast_var_name(current), "SKINNY_AUTOANSWER"))) {
if (d->hookstate == SKINNY_ONHOOK && !sub->aa_sched) {
@@ -5001,6 +5018,7 @@
if (doautoanswer) {
setsubstate(sub, SUBSTATE_CONNECTED);
}
+ skinny_unlocksub(sub);
return res;
}
@@ -5573,6 +5591,8 @@
return;
}
+ skinny_locksub(sub);
+
if (sub->dialer_sched) {
skinny_sched_del(sub->dialer_sched, sub);
sub->dialer_sched = 0;
@@ -5590,6 +5610,7 @@
if (skinny_sched_del(sub->cfwd_sched, sub)) {
SKINNY_DEBUG(DEBUG_SUB, 3, "Sub %d - trying to change state from %s to %s, but already forwarded because no answer.\n",
sub->callid, substate2str(sub->substate), substate2str(actualstate));
+ skinny_unlocksub(sub);
return;
}
sub->cfwd_sched = 0;
@@ -5666,12 +5687,11 @@
sub->cxmode = SKINNY_CX_RECVONLY;
sub->substate = SUBSTATE_ONHOOK;
- destroy_rtp(sub);
sub->substate = SUBSTATE_ONHOOK;
if (sub->owner) {
ast_queue_hangup(sub->owner);
}
- return;
+ break;
case SUBSTATE_CONNECTED:
transmit_activatecallplane(d, l);
transmit_stop_tone(d, l->instance, sub->callid);
@@ -5691,7 +5711,7 @@
}
sub->substate = SUBSTATE_CONNECTED;
l->activesub = sub;
- return;
+ break;
case SUBSTATE_HOLD:
if (sub->substate != SUBSTATE_CONNECTED) {
ast_log(LOG_WARNING, "Cannot set substate to SUBSTATE_HOLD from %s (on call-%d)\n", substate2str(sub->substate), sub->callid);
@@ -5709,10 +5729,12 @@
ast_queue_hold(sub->owner, l->mohsuggest);
- return;
+ break;
default:
ast_log(LOG_WARNING, "Substate handling under subline for state %d not implemented on Sub-%d\n", state, sub->callid);
}
+ skinny_unlocksub(sub);
+ return;
}
if ((d->hookstate == SKINNY_ONHOOK) && ((actualstate == SUBSTATE_OFFHOOK) || (actualstate == SUBSTATE_DIALING)
@@ -5726,6 +5748,7 @@
sub->callid, substate2str(sub->substate), substate2str(actualstate));
if (actualstate == sub->substate) {
+ skinny_unlocksub(sub);
return;
}
@@ -5766,10 +5789,10 @@
}
sub->cxmode = SKINNY_CX_RECVONLY;
- destroy_rtp(sub);
if (sub->owner) {
if (sub->substate == SUBSTATE_OFFHOOK) {
sub->substate = SUBSTATE_ONHOOK;
+ skinny_unlocksub(sub);
ast_hangup(sub->owner);
} else {
sub->substate = SUBSTATE_ONHOOK;
@@ -5782,7 +5805,7 @@
case SUBSTATE_DIALING:
if (ast_strlen_zero(sub->exten) || !ast_exists_extension(c, ast_channel_context(c), sub->exten, 1, l->cid_num)) {
ast_log(LOG_WARNING, "Exten (%s)@(%s) does not exist, unable to set substate DIALING on sub %d\n", sub->exten, ast_channel_context(c), sub->callid);
- return;
+ break;
}
if (d->hookstate == SKINNY_ONHOOK) {
@@ -5825,7 +5848,7 @@
case SUBSTATE_RINGOUT:
if (!(sub->substate == SUBSTATE_DIALING || sub->substate == SUBSTATE_PROGRESS)) {
ast_log(LOG_WARNING, "Cannot set substate to SUBSTATE_RINGOUT from %s (on call-%d)\n", substate2str(sub->substate), sub->callid);
- return;
+ break;
}
if (sub->substate != SUBSTATE_PROGRESS) {
transmit_callstate(d, l->instance, sub->callid, SKINNY_PROGRESS);
@@ -5923,7 +5946,7 @@
case SUBSTATE_BUSY:
if (!(sub->substate == SUBSTATE_DIALING || sub->substate == SUBSTATE_PROGRESS || sub->substate == SUBSTATE_RINGOUT)) {
ast_log(LOG_WARNING, "Cannot set substate to SUBSTATE_BUSY from %s (on call-%d)\n", substate2str(sub->substate), sub->callid);
- return;
+ break;
}
if (!d->earlyrtp) {
@@ -5937,7 +5960,7 @@
case SUBSTATE_CONGESTION:
if (!(sub->substate == SUBSTATE_DIALING || sub->substate == SUBSTATE_PROGRESS || sub->substate == SUBSTATE_RINGOUT)) {
ast_log(LOG_WARNING, "Cannot set substate to SUBSTATE_CONGESTION from %s (on call-%d)\n", substate2str(sub->substate), sub->callid);
- return;
+ break;
}
if (!d->earlyrtp) {
@@ -5951,7 +5974,7 @@
case SUBSTATE_PROGRESS:
if (sub->substate != SUBSTATE_DIALING) {
ast_log(LOG_WARNING, "Cannot set substate to SUBSTATE_PROGRESS from %s (on call-%d)\n", substate2str(sub->substate), sub->callid);
- return;
+ break;
}
if (!d->earlyrtp) {
@@ -5965,7 +5988,7 @@
case SUBSTATE_HOLD:
if (sub->substate != SUBSTATE_CONNECTED) {
ast_log(LOG_WARNING, "Cannot set substate to SUBSTATE_HOLD from %s (on call-%d)\n", substate2str(sub->substate), sub->callid);
- return;
+ break;
}
ast_queue_hold(sub->owner, l->mohsuggest);
@@ -5981,6 +6004,7 @@
default:
ast_log(LOG_WARNING, "Was asked to change to nonexistant substate %d on Sub-%d\n", state, sub->callid);
}
+ skinny_unlocksub(sub);
}
static void dumpsub(struct skinny_subchannel *sub, int forcehangup)
@@ -6042,8 +6066,6 @@
SKINNY_DEBUG(DEBUG_SUB, 3, "Sub %d - Activating, and deactivating sub %d\n",
sub->callid, l->activesub ? l->activesub->callid : 0);
- ast_channel_lock(sub->owner);
-
if (sub == l->activesub) {
setsubstate(sub, state);
} else {
@@ -6057,8 +6079,6 @@
l->activesub = sub;
setsubstate(sub, state);
}
-
- ast_channel_unlock(sub->owner);
}
static void dialandactivatesub(struct skinny_subchannel *sub, char exten[AST_MAX_EXTENSION])
More information about the asterisk-commits
mailing list