[Asterisk-code-review] app_confbridge: Fix bridge shutdown race condition. (asterisk[master])

N A asteriskteam at digium.com
Thu Dec 22 08:01:21 CST 2022


Hello Joshua Colp, Friendly Automation, 

I'd like you to reexamine a change. Please visit

    https://gerrit.asterisk.org/c/asterisk/+/18577

to look at the new patch set (#3).

Change subject: app_confbridge: Fix bridge shutdown race condition.
......................................................................

app_confbridge: Fix bridge shutdown race condition.

A race condition exists where if a bridge is left vacant
for a split instant, the bridge will shut down and go
away at the same instant that somebody else could be trying
to join it. The newcomer will find the conference still
in conference_bridges and thus take it and run with it.
At the same time, shutdown of the bridge completes and it
is removed from conference_bridges. This would generally
be rare since the timing must line up exactly right, but
if the timing is right, it can happen very frequently.

As a result, the newcomer will end up joining the bridge
corresponding to the original conference that is now
defunct. When the next party joins the same named bridge,
it won't be found in conference_bridges and thus a new
bridge gets created. This can happen right afterwards,
but in theory it could happen at any point after the first.

As a result, the newcomer that joined the bridge during
the shutdown ends up stranded in a bridge that isn't
known to app_confbridge anymore and will never get conferenced
with anything, since it's been removed from the list of
conferences already.

To prevent this, if the conference is empty when we try
to join it, we now clean it up then and there and then
make the new bridge immediately.

Additionally, we now check after we join the bridge
if the same conference object is returned when searching
for it. If it isn't, then we try to join the bridge again,
which will succeed the second time since we won't find
the shutting down conference anymore.

ASTERISK-30081 #close

Change-Id: I08a440eafbf83ec4b502d1e44c3f4d44c4a522f9
---
M apps/app_confbridge.c
1 file changed, 77 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/77/18577/3
-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18577
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I08a440eafbf83ec4b502d1e44c3f4d44c4a522f9
Gerrit-Change-Number: 18577
Gerrit-PatchSet: 3
Gerrit-Owner: N A <asterisk at phreaknet.org>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: N A <asterisk at phreaknet.org>
Gerrit-MessageType: newpatchset
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221222/34290ff4/attachment-0001.html>


More information about the asterisk-code-review mailing list