mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 20:56:39 +00:00
stasis: Don't hold app_registry and session locks unnecessarily
resource_events:stasis_app_message_handler() was locking the session, then attempting to determine if the app had debug enabled which locked the app_registry container. res_stasis:__stasis_app_register was locking the app_registry container then calling app_update which caused app_handler (which locks the session) to run. The result was a deadlock. * Updated resource_events:stasis_app_message_handler() to determine if debug was set (which locks the app_registry) before obtaining the session lock. * Updated res_stasis:__stasis_app_register to release the app_registry container lock before calling app_update (which locks the sesison). ASTERISK-28423 Reported by Ross Beer Change-Id: I58c69d08cb372852a63933608e4d6c3e456247b4
This commit is contained in:
@@ -81,9 +81,16 @@ static void stasis_app_message_handler(
|
||||
{
|
||||
struct event_session *session = data;
|
||||
const char *msg_type, *msg_application;
|
||||
int app_debug_enabled;
|
||||
|
||||
ast_assert(session != NULL);
|
||||
|
||||
/*
|
||||
* We need to get the debug flag before lockinf session
|
||||
* to help prevent a deadlock with the apps_registry container.
|
||||
*/
|
||||
app_debug_enabled = stasis_app_get_debug_by_name(app_name);
|
||||
|
||||
ao2_lock(session);
|
||||
|
||||
msg_type = S_OR(ast_json_string_get(ast_json_object_get(message, "type")), "");
|
||||
@@ -115,7 +122,7 @@ static void stasis_app_message_handler(
|
||||
msg_type,
|
||||
msg_application);
|
||||
} else if (stasis_app_event_allowed(app_name, message)) {
|
||||
if (stasis_app_get_debug_by_name(app_name)) {
|
||||
if (app_debug_enabled) {
|
||||
char *str = ast_json_dump_string_format(message, ast_ari_json_format());
|
||||
|
||||
ast_verbose("<--- Sending ARI event to %s --->\n%s\n",
|
||||
@@ -310,7 +317,6 @@ static void event_session_dtor(void *obj)
|
||||
{
|
||||
#ifdef AST_DEVMODE /* Avoid unused variable warning */
|
||||
struct event_session *session = obj;
|
||||
|
||||
#endif
|
||||
|
||||
/* event_session_shutdown should have been called before now */
|
||||
|
Reference in New Issue
Block a user