Fix multi-station answer race condition.

When an SLA trunk is ringing (inbound call on the trunk) Asterisk will
make outbound calls to the stations that have that trunk.  If more than
one station answers the call at the same time, all channels other than
the first one to answer are left in a bad state.  The channel gets
leaked, is not connected to anything, and there's no way to get rid of
it.

We now properly clean up these losing channels by hanging up on them.
Since they lost the race, as we process their answer, there is no
ringing trunk for them to answer.
........

Merged revisions 383835 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 383836 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383837 65c4cc65-6c06-0410-ace0-fbb531ad65f3
changes/78/78/1
Russell Bryant 13 years ago
parent 23f363fcb1
commit 03047a47b6

@ -5926,7 +5926,16 @@ static void sla_handle_dial_state_event(void)
ringing_trunk = sla_choose_ringing_trunk(ringing_station->station, &s_trunk_ref, 1); ringing_trunk = sla_choose_ringing_trunk(ringing_station->station, &s_trunk_ref, 1);
ast_mutex_unlock(&sla.lock); ast_mutex_unlock(&sla.lock);
if (!ringing_trunk) { if (!ringing_trunk) {
/* This case happens in a bit of a race condition. If two stations answer
* the outbound call at the same time, the first one will get connected to
* the trunk. When the second one gets here, it will not see any trunks
* ringing so we have no idea what to conect it to. So, we just hang up
* on it. */
ast_debug(1, "Found no ringing trunk for station '%s' to answer!\n", ringing_station->station->name); ast_debug(1, "Found no ringing trunk for station '%s' to answer!\n", ringing_station->station->name);
ast_dial_join(ringing_station->station->dial);
ast_dial_destroy(ringing_station->station->dial);
ringing_station->station->dial = NULL;
ast_free(ringing_station);
break; break;
} }
/* Track the channel that answered this trunk */ /* Track the channel that answered this trunk */

Loading…
Cancel
Save