diff --git a/main/pbx_app.c b/main/pbx_app.c index e0609db70e612bc9326ad7fae629928f3e21d145..ec6bc75890a5fd7d8d5ac012b0fd4b131fe36cfd 100644 --- a/main/pbx_app.c +++ b/main/pbx_app.c @@ -394,6 +394,11 @@ int ast_unregister_application(const char *app) 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); @@ -416,6 +421,8 @@ int ast_unregister_application(const char *app) AST_RWLIST_TRAVERSE_SAFE_END; AST_RWLIST_UNLOCK(&apps); + ast_unlock_contexts(); + return cur ? 0 : -1; }