]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix multi-station answer race condition.
authorRussell Bryant <russell@russellbryant.com>
Tue, 26 Mar 2013 01:32:27 +0000 (01:32 +0000)
committerRussell Bryant <russell@russellbryant.com>
Tue, 26 Mar 2013 01:32:27 +0000 (01:32 +0000)
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.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@383835 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_meetme.c

index b51e18018d7f8428b05e201135a430b7fad16742..afcf0778052c66f39d3d9fe8e3af5202be70c30e 100644 (file)
@@ -5637,7 +5637,16 @@ static void sla_handle_dial_state_event(void)
                        ringing_trunk = sla_choose_ringing_trunk(ringing_station->station, &s_trunk_ref, 1);
                        ast_mutex_unlock(&sla.lock);
                        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_dial_join(ringing_station->station->dial);
+                               ast_dial_destroy(ringing_station->station->dial);
+                               ringing_station->station->dial = NULL;
+                               ast_free(ringing_station);
                                break;
                        }
                        /* Track the channel that answered this trunk */