diff options
Diffstat (limited to 'main/pbx.c')
-rw-r--r-- | main/pbx.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/main/pbx.c b/main/pbx.c index 6bb8a14f6..9654bd88f 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -4022,7 +4022,7 @@ int ast_context_remove_extension(const char *context, const char *extension, int struct ast_context *c = find_context_locked(context); if (c) { /* ... remove extension ... */ - ret = ast_context_remove_extension2(c, extension, priority, registrar); + ret = ast_context_remove_extension2(c, extension, priority, registrar, 1); ast_unlock_contexts(); } return ret; @@ -4038,14 +4038,15 @@ int ast_context_remove_extension(const char *context, const char *extension, int * it. * */ -int ast_context_remove_extension2(struct ast_context *con, const char *extension, int priority, const char *registrar) +int ast_context_remove_extension2(struct ast_context *con, const char *extension, int priority, const char *registrar, int already_locked) { struct ast_exten *exten, *prev_exten = NULL; struct ast_exten *peer; struct ast_exten ex, *exten2, *exten3; char dummy_name[1024]; - ast_wrlock_context(con); + if (!already_locked) + ast_wrlock_context(con); /* Handle this is in the new world */ @@ -4132,7 +4133,8 @@ int ast_context_remove_extension2(struct ast_context *con, const char *extension } if (!exten) { /* we can't find right extension */ - ast_unlock_context(con); + if (!already_locked) + ast_unlock_context(con); return -1; } @@ -4159,7 +4161,8 @@ int ast_context_remove_extension2(struct ast_context *con, const char *extension break; /* found our priority */ } if (!peer) { /* not found */ - ast_unlock_context(con); + if (!already_locked) + ast_unlock_context(con); return -1; } /* we are first priority extension? */ @@ -4192,7 +4195,8 @@ int ast_context_remove_extension2(struct ast_context *con, const char *extension destroy_exten(peer); /* XXX should we return -1 ? */ } - ast_unlock_context(con); + if (!already_locked) + ast_unlock_context(con); return 0; } @@ -7177,7 +7181,7 @@ void __ast_context_destroy(struct ast_context *list, struct ast_hashtab *context ast_verb(3, "Remove %s/%s/%d, registrar=%s; con=%s(%p); con->root=%p\n", tmp->name, prio_item->exten, prio_item->priority, registrar, con? con->name : "<nil>", con, con? con->root_table: NULL); - ast_context_remove_extension2(tmp, prio_item->exten, prio_item->priority, registrar); + ast_context_remove_extension2(tmp, prio_item->exten, prio_item->priority, registrar, 1); } ast_hashtab_end_traversal(prio_iter); } |