mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-24 05:38:11 +00:00
(closes issue #12689)
Reported by: ys Many thanks to ys for doing the research on this problem. I didn't think it would be best to unlock the contexts and then relock them after the remove_extension2() call, so I added an extra arg to remove_extension2() and set it appropriately in each call. There were not that many. I considered forcing the code to lock the contexts before the call to remove_extension2(), but that would require a slightly greater degree of changes, especially since the find_context_locked is local to pbx.c I did a simple sanity test to make sure the code doesn't mess things up in general. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@123165 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -2098,7 +2098,7 @@ static int unload_module(void)
|
|||||||
res |= ast_unregister_application(rapp);
|
res |= ast_unregister_application(rapp);
|
||||||
|
|
||||||
if ((con = ast_context_find("app_dial_gosub_virtual_context"))) {
|
if ((con = ast_context_find("app_dial_gosub_virtual_context"))) {
|
||||||
ast_context_remove_extension2(con, "s", 1, NULL);
|
ast_context_remove_extension2(con, "s", 1, NULL, 0);
|
||||||
ast_context_destroy(con, "app_dial"); /* leave nothing behind */
|
ast_context_destroy(con, "app_dial"); /* leave nothing behind */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6366,7 +6366,7 @@ static int unload_module(void)
|
|||||||
ast_event_unsubscribe(device_state_sub);
|
ast_event_unsubscribe(device_state_sub);
|
||||||
|
|
||||||
if ((con = ast_context_find("app_queue_gosub_virtual_context"))) {
|
if ((con = ast_context_find("app_queue_gosub_virtual_context"))) {
|
||||||
ast_context_remove_extension2(con, "s", 1, NULL);
|
ast_context_remove_extension2(con, "s", 1, NULL, 0);
|
||||||
ast_context_destroy(con, "app_queue"); /* leave no trace */
|
ast_context_destroy(con, "app_queue"); /* leave no trace */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ static int unload_module(void)
|
|||||||
ast_agi_unregister(ast_module_info->self, &gosub_agi_command);
|
ast_agi_unregister(ast_module_info->self, &gosub_agi_command);
|
||||||
|
|
||||||
if ((con = ast_context_find("app_stack_gosub_virtual_context"))) {
|
if ((con = ast_context_find("app_stack_gosub_virtual_context"))) {
|
||||||
ast_context_remove_extension2(con, "s", 1, NULL);
|
ast_context_remove_extension2(con, "s", 1, NULL, 0);
|
||||||
ast_context_destroy(con, "app_stack"); /* leave nothing behind */
|
ast_context_destroy(con, "app_stack"); /* leave nothing behind */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -600,7 +600,7 @@ int ast_context_remove_extension(const char *context, const char *extension, int
|
|||||||
const char *registrar);
|
const char *registrar);
|
||||||
|
|
||||||
int ast_context_remove_extension2(struct ast_context *con, const char *extension,
|
int ast_context_remove_extension2(struct ast_context *con, const char *extension,
|
||||||
int priority, const char *registrar);
|
int priority, const char *registrar, int already_locked);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Add an ignorepat
|
* \brief Add an ignorepat
|
||||||
|
|||||||
@@ -2465,7 +2465,7 @@ int manage_parkinglot(struct ast_parkinglot *curlot, fd_set *rfds, fd_set *efds,
|
|||||||
/* And take them out of the parking lot */
|
/* And take them out of the parking lot */
|
||||||
con = ast_context_find(pu->parkinglot->parking_con);
|
con = ast_context_find(pu->parkinglot->parking_con);
|
||||||
if (con) {
|
if (con) {
|
||||||
if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL))
|
if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL, 0))
|
||||||
ast_log(LOG_WARNING, "Whoa, failed to remove the parking extension!\n");
|
ast_log(LOG_WARNING, "Whoa, failed to remove the parking extension!\n");
|
||||||
else
|
else
|
||||||
notify_metermaids(pu->parkingexten, curlot->parking_con, AST_DEVICE_NOT_INUSE);
|
notify_metermaids(pu->parkingexten, curlot->parking_con, AST_DEVICE_NOT_INUSE);
|
||||||
@@ -2500,7 +2500,7 @@ int manage_parkinglot(struct ast_parkinglot *curlot, fd_set *rfds, fd_set *efds,
|
|||||||
/* And take them out of the parking lot */
|
/* And take them out of the parking lot */
|
||||||
con = ast_context_find(curlot->parking_con);
|
con = ast_context_find(curlot->parking_con);
|
||||||
if (con) {
|
if (con) {
|
||||||
if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL))
|
if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL, 0))
|
||||||
ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
|
ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
|
||||||
else
|
else
|
||||||
notify_metermaids(pu->parkingexten, curlot->parking_con, AST_DEVICE_NOT_INUSE);
|
notify_metermaids(pu->parkingexten, curlot->parking_con, AST_DEVICE_NOT_INUSE);
|
||||||
@@ -2721,7 +2721,7 @@ static int park_exec_full(struct ast_channel *chan, void *data, struct ast_parki
|
|||||||
peer = pu->chan;
|
peer = pu->chan;
|
||||||
con = ast_context_find(parkinglot->parking_con);
|
con = ast_context_find(parkinglot->parking_con);
|
||||||
if (con) {
|
if (con) {
|
||||||
if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL))
|
if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL, 0))
|
||||||
ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
|
ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
|
||||||
else
|
else
|
||||||
notify_metermaids(pu->parkingexten, parkinglot->parking_con, AST_DEVICE_NOT_INUSE);
|
notify_metermaids(pu->parkingexten, parkinglot->parking_con, AST_DEVICE_NOT_INUSE);
|
||||||
@@ -3284,7 +3284,7 @@ static int load_config(void)
|
|||||||
|
|
||||||
/* Remove the old parking extension */
|
/* Remove the old parking extension */
|
||||||
if (!ast_strlen_zero(old_parking_con) && (con = ast_context_find(old_parking_con))) {
|
if (!ast_strlen_zero(old_parking_con) && (con = ast_context_find(old_parking_con))) {
|
||||||
if(ast_context_remove_extension2(con, old_parking_ext, 1, registrar))
|
if(ast_context_remove_extension2(con, old_parking_ext, 1, registrar, 0))
|
||||||
notify_metermaids(old_parking_ext, old_parking_con, AST_DEVICE_NOT_INUSE);
|
notify_metermaids(old_parking_ext, old_parking_con, AST_DEVICE_NOT_INUSE);
|
||||||
ast_debug(1, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con);
|
ast_debug(1, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con);
|
||||||
}
|
}
|
||||||
|
|||||||
10
main/pbx.c
10
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);
|
struct ast_context *c = find_context_locked(context);
|
||||||
|
|
||||||
if (c) { /* ... remove extension ... */
|
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();
|
ast_unlock_contexts();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@@ -4038,13 +4038,14 @@ int ast_context_remove_extension(const char *context, const char *extension, int
|
|||||||
* it.
|
* 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 *exten, *prev_exten = NULL;
|
||||||
struct ast_exten *peer;
|
struct ast_exten *peer;
|
||||||
struct ast_exten ex, *exten2, *exten3;
|
struct ast_exten ex, *exten2, *exten3;
|
||||||
char dummy_name[1024];
|
char dummy_name[1024];
|
||||||
|
|
||||||
|
if (!already_locked)
|
||||||
ast_wrlock_context(con);
|
ast_wrlock_context(con);
|
||||||
|
|
||||||
/* Handle this is in the new world */
|
/* Handle this is in the new world */
|
||||||
@@ -4132,6 +4133,7 @@ int ast_context_remove_extension2(struct ast_context *con, const char *extension
|
|||||||
}
|
}
|
||||||
if (!exten) {
|
if (!exten) {
|
||||||
/* we can't find right extension */
|
/* we can't find right extension */
|
||||||
|
if (!already_locked)
|
||||||
ast_unlock_context(con);
|
ast_unlock_context(con);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -4159,6 +4161,7 @@ int ast_context_remove_extension2(struct ast_context *con, const char *extension
|
|||||||
break; /* found our priority */
|
break; /* found our priority */
|
||||||
}
|
}
|
||||||
if (!peer) { /* not found */
|
if (!peer) { /* not found */
|
||||||
|
if (!already_locked)
|
||||||
ast_unlock_context(con);
|
ast_unlock_context(con);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -4192,6 +4195,7 @@ int ast_context_remove_extension2(struct ast_context *con, const char *extension
|
|||||||
destroy_exten(peer);
|
destroy_exten(peer);
|
||||||
/* XXX should we return -1 ? */
|
/* XXX should we return -1 ? */
|
||||||
}
|
}
|
||||||
|
if (!already_locked)
|
||||||
ast_unlock_context(con);
|
ast_unlock_context(con);
|
||||||
return 0;
|
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",
|
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);
|
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);
|
ast_hashtab_end_traversal(prio_iter);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user