[asterisk-commits] Core/PBX: Deadlock between dialplan execution and applicatio... (asterisk[14])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jun 16 16:18:14 CDT 2017
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5869 )
Change subject: Core/PBX: Deadlock between dialplan execution and application unregistration.
......................................................................
Core/PBX: Deadlock between dialplan execution and application unregistration.
Not easy to reproduce, but we have noticed deadlocks when unloading a module
while dialplan is handling a request.
The deadlock is between :
1) Dialplan execution: pbx_extension_helper() first taking conlock,
then pbx_findapp() [when called] asking for lock on apps list.
2) Application unregistration: ast_unregister_application() first taking lock
on apps list, then unreference_cached_app() [when called] asking for conlock.
As a protection, I suggest to modify ast_unregister_application(), so that it
anticipates the need of conlock, before taking the lock on apps list.
The side effect is a longer unavailability of conlock when unregistering an
application.
ASTERISK-27041
Change-Id: I0db0f1eb320da6a5758cce3a47d765be1face8e2
---
M main/pbx_app.c
1 file changed, 7 insertions(+), 0 deletions(-)
Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
Matthew Fredrickson: Looks good to me, approved
Jenkins2: Approved for Submit
diff --git a/main/pbx_app.c b/main/pbx_app.c
index 7dabda3..e39ad3f 100644
--- a/main/pbx_app.c
+++ b/main/pbx_app.c
@@ -396,6 +396,11 @@
struct ast_app *cur;
int cmp;
+ /* Anticipate need for conlock in unreference_cached_app(), in order to avoid
+ * possible deadlock with pbx_extension_helper()/pbx_findapp()
+ */
+ ast_rdlock_contexts();
+
AST_RWLIST_WRLOCK(&apps);
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&apps, cur, list) {
cmp = strcasecmp(app, cur->name);
@@ -418,6 +423,8 @@
AST_RWLIST_TRAVERSE_SAFE_END;
AST_RWLIST_UNLOCK(&apps);
+ ast_unlock_contexts();
+
return cur ? 0 : -1;
}
--
To view, visit https://gerrit.asterisk.org/5869
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-MessageType: merged
Gerrit-Change-Id: I0db0f1eb320da6a5758cce3a47d765be1face8e2
Gerrit-Change-Number: 5869
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Frederic LE FOLL <frederic.lefoll at c-s.fr>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20170616/2f56063e/attachment-0001.html>
More information about the asterisk-commits
mailing list