diff --git a/res/res_stasis.c b/res/res_stasis.c index fe89da567aca8797753a48dd643788592c18f81f..64f05ef72670bee59856ef87f98e820412c1b608 100644 --- a/res/res_stasis.c +++ b/res/res_stasis.c @@ -1715,12 +1715,11 @@ static int __stasis_app_register(const char *app_name, stasis_app_cb handler, vo if (app) { /* * We need to unlock the apps_registry before calling app_update to - * prevent the possibility of a deadlock with the session. We'll still - * run the lazy cleanup first though. + * prevent the possibility of a deadlock with the session. */ - cleanup(); ao2_unlock(apps_registry); app_update(app, handler, data); + cleanup(); return 0; } @@ -1745,11 +1744,12 @@ static int __stasis_app_register(const char *app_name, stasis_app_cb handler, vo } ao2_link_flags(apps_registry, app, OBJ_NOLOCK); + ao2_unlock(apps_registry); + /* We lazily clean up the apps_registry, because it's good enough to * prevent memory leaks, and we're lazy. */ cleanup(); - ao2_unlock(apps_registry); return 0; }