}
if (e->exten[0] == '_') {
- /* Create this hint on-the-fly */
+ /* Create this hint on-the-fly, we explicitly lock hints here to ensure the
+ * same locking order as if this were done through configuration file - that is
+ * hints is locked first and then (if needed) contexts is locked
+ */
+ ao2_lock(hints);
ast_add_extension(e->parent->name, 0, exten, e->priority, e->label,
e->matchcid ? e->cidmatch : NULL, e->app, ast_strdup(e->data), ast_free_ptr,
e->registrar);
+ ao2_unlock(hints);
if (!(e = ast_hint_extension(c, context, exten))) {
/* Improbable, but not impossible */
return -1;
if (e->exten[0] == '_') {
/* Create this hint on-the-fly */
+ ao2_lock(hints);
ast_add_extension(e->parent->name, 0, exten, e->priority, e->label,
e->matchcid ? e->cidmatch : NULL, e->app, ast_strdup(e->data), ast_free_ptr,
e->registrar);
+ ao2_unlock(hints);
if (!(e = ast_hint_extension(c, context, exten))) {
/* Improbable, but not impossible */
return -1;
* individual extension, because the pattern will no longer match first.
*/
if (e->exten[0] == '_') {
+ ao2_lock(hints);
ast_add_extension(e->parent->name, 0, exten, e->priority, e->label,
e->matchcid ? e->cidmatch : NULL, e->app, ast_strdup(e->data), ast_free_ptr,
e->registrar);
+ ao2_unlock(hints);
e = ast_hint_extension(NULL, context, exten);
if (!e || e->exten[0] == '_') {
return -1;