[Asterisk-code-review] stasis/control: Fix possible deadlock with swap channel (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Tue Sep 5 16:04:03 CDT 2017


Richard Mudgett has posted comments on this change. ( https://gerrit.asterisk.org/6366 )

Change subject: stasis/control:  Fix possible deadlock with swap channel
......................................................................


Patch Set 2: Code-Review-1

(5 comments)

One minor finding with some code optimizations.

https://gerrit.asterisk.org/#/c/6366/2/main/bridge_after.c
File main/bridge_after.c:

https://gerrit.asterisk.org/#/c/6366/2/main/bridge_after.c@298
PS2, Line 298: const char *reason_strings[] = {
This should be made static.

Better would be to make ast_bridge_after_cb_reason_string() use a switch statement returning the strings.


https://gerrit.asterisk.org/#/c/6366/2/main/bridge_after.c@309
PS2, Line 309: 	if (reason < AST_BRIDGE_AFTER_CB_REASON_DESTROY
             : 		|| AST_BRIDGE_AFTER_CB_REASON_REMOVED < reason
             : 		|| !reason_strings[reason]) {
This expression needs updating.

Probably be better to change it to a switch with a case for each enum returning the string.


https://gerrit.asterisk.org/#/c/6366/2/res/stasis/control.c
File res/stasis/control.c:

https://gerrit.asterisk.org/#/c/6366/2/res/stasis/control.c@964
PS2, Line 964: 	/* No longer in the bridge */
             : 	control->bridge = NULL;
This can be pulled into the if (control->bridge) clause.  Also this clause could be in the same order as the code before this patch.

Before:
code block

After:
if (control->bridge) {
  code block
}


https://gerrit.asterisk.org/#/c/6366/2/res/stasis/control.c@1039
PS2, Line 1039: 		SCOPED_AO2LOCK(lock, control);
This scoped lock usage is compromised and can easily be eliminated.  As it is you now have a path after ast_bridge_impart() where control is locked just so the scoped lock can unlock it.


https://gerrit.asterisk.org/#/c/6366/2/res/stasis/control.c@1058
PS2, Line 1058: 		control->bridge = bridge;
We could keep the assert checking that control->bridge was NULL before we set the bridge here.



-- 
To view, visit https://gerrit.asterisk.org/6366
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: comment
Gerrit-Change-Id: Ifd239aa93955b3eb475521f61e284fcb0da2c3b3
Gerrit-Change-Number: 6366
Gerrit-PatchSet: 2
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Comment-Date: Tue, 05 Sep 2017 21:04:03 +0000
Gerrit-HasComments: Yes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170905/94bf0507/attachment.html>


More information about the asterisk-code-review mailing list