[Asterisk-code-review] pbx.c: Store hints by name. (asterisk[16])
Benjamin Keith Ford
asteriskteam at digium.com
Thu Oct 28 11:27:20 CDT 2021
Benjamin Keith Ford has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/16662 )
Change subject: pbx.c: Store hints by name.
......................................................................
pbx.c: Store hints by name.
When reloading dialplan, hints created dynamically would lose any dash
characters. Now the name is stored, so use that when performing a reload
instead of the exten.
Change-Id: I95e48f5a268efa3c6840ab69798525d3dce91636
---
M main/pbx.c
1 file changed, 7 insertions(+), 4 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/62/16662/1
diff --git a/main/pbx.c b/main/pbx.c
index d0ee127..492ad71 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -6278,6 +6278,7 @@
struct store_hint {
char *context;
+ char *name;
char *exten;
AST_LIST_HEAD_NOLOCK(, ast_state_cb) callbacks;
int laststate;
@@ -6463,7 +6464,6 @@
}
}
-
/* XXX this does not check that multiple contexts are merged */
void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar)
{
@@ -6538,7 +6538,7 @@
}
exten_len = strlen(hint->exten->exten) + 1;
- length = exten_len + strlen(hint->exten->parent->name) + 1
+ length = strlen(hint->exten->name) + 1 + exten_len + strlen(hint->exten->parent->name) + 1
+ sizeof(*saved_hint);
if (!(saved_hint = ast_calloc(1, length))) {
ao2_unlock(hint);
@@ -6559,6 +6559,9 @@
strcpy(saved_hint->data, hint->exten->parent->name);
saved_hint->exten = saved_hint->data + strlen(saved_hint->context) + 1;
ast_copy_string(saved_hint->exten, hint->exten->exten, exten_len);
+ saved_hint->name = saved_hint->data + strlen(saved_hint->context) + strlen(saved_hint->exten) + 2;
+ strcpy(saved_hint->name, hint->exten->name);
+
if (hint->last_presence_subtype) {
saved_hint->last_presence_subtype = ast_strdup(hint->last_presence_subtype);
}
@@ -6595,12 +6598,12 @@
* individual extension, because the pattern will no longer match first.
*/
if (exten && exten->exten[0] == '_') {
- ast_add_extension_nolock(exten->parent->name, 0, saved_hint->exten,
+ ast_add_extension_nolock(exten->parent->name, 0, saved_hint->name,
PRIORITY_HINT, NULL, 0, exten->app, ast_strdup(exten->data), ast_free_ptr,
exten->registrar);
/* rwlocks are not recursive locks */
exten = ast_hint_extension_nolock(NULL, saved_hint->context,
- saved_hint->exten);
+ saved_hint->name);
}
/* Find the hint in the hints container */
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16662
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I95e48f5a268efa3c6840ab69798525d3dce91636
Gerrit-Change-Number: 16662
Gerrit-PatchSet: 1
Gerrit-Owner: Benjamin Keith Ford <bford at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211028/e338e4ef/attachment.html>
More information about the asterisk-code-review
mailing list