mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 00:30:20 +00:00
Merge "stasis/app: don't lock an app before a call to send" into 16
This commit is contained in:
@@ -1166,8 +1166,23 @@ void app_update(struct stasis_app *app, stasis_app_cb handler, void *data)
|
|||||||
"timestamp", ast_json_timeval(ast_tvnow(), NULL),
|
"timestamp", ast_json_timeval(ast_tvnow(), NULL),
|
||||||
"application", app->name);
|
"application", app->name);
|
||||||
if (msg) {
|
if (msg) {
|
||||||
|
/*
|
||||||
|
* The app must be unlocked before calling 'send' since a handler may
|
||||||
|
* subsequently attempt to grab the app lock after first obtaining a
|
||||||
|
* lock for another object, thus causing a deadlock.
|
||||||
|
*/
|
||||||
|
ao2_unlock(app);
|
||||||
app_send(app, msg);
|
app_send(app, msg);
|
||||||
|
ao2_lock(app);
|
||||||
ast_json_unref(msg);
|
ast_json_unref(msg);
|
||||||
|
if (!app->handler) {
|
||||||
|
/*
|
||||||
|
* If the handler disappeared then the app was deactivated. In that
|
||||||
|
* case don't replace. Re-activation will reset the handler later.
|
||||||
|
*/
|
||||||
|
ao2_unlock(app);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ast_verb(1, "Activating Stasis app '%s'\n", app->name);
|
ast_verb(1, "Activating Stasis app '%s'\n", app->name);
|
||||||
|
|||||||
Reference in New Issue
Block a user