[Asterisk-code-review] res_pjsip_config_wizard: Fix change detection for wizard settings (asterisk[13])

Friendly Automation asteriskteam at digium.com
Tue Jan 7 12:38:18 CST 2020


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/13510 )

Change subject: res_pjsip_config_wizard: Fix change detection for wizard settings
......................................................................

res_pjsip_config_wizard: Fix change detection for wizard settings

ast_sorcery_changeset_create() is not commutative and will fail to detect
differences between two variable lists depending on what changed, so switch to
ast_variable_lists_match().

ASTERISK-28492 #close
Reported by: Jean-Denis Girard

Change-Id: I7b3256983ddfaa2138d3de92a444a53b5193a4e1
---
M res/res_pjsip_config_wizard.c
1 file changed, 3 insertions(+), 4 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/res/res_pjsip_config_wizard.c b/res/res_pjsip_config_wizard.c
index 0bdedd5..383a2d5 100644
--- a/res/res_pjsip_config_wizard.c
+++ b/res/res_pjsip_config_wizard.c
@@ -1103,18 +1103,17 @@
 	while ((category = ast_category_browse_filtered(cfg, NULL, category, "type=^wizard$"))) {
 		const char *id = ast_category_get_name(category);
 		struct ast_category *last_cat = NULL;
-		struct ast_variable *change_set = NULL;
+		int changes = 0;
 
 		if (otw->last_config) {
 			last_cat = ast_category_get(otw->last_config, id, "type=^wizard$");
-			ast_sorcery_changeset_create(ast_category_first(category), ast_category_first(last_cat), &change_set);
+			changes = !ast_variable_lists_match(ast_category_first(category), ast_category_first(last_cat), 1);
 			if (last_cat) {
 				ast_category_delete(otw->last_config, last_cat);
 			}
 		}
 
-		if (!last_cat || change_set) {
-			ast_variables_destroy(change_set);
+		if (!last_cat || changes) {
 			ast_debug(3, "%s: %s(s) for wizard '%s'\n", reloaded ? "Reload" : "Load", object_type, id);
 			if (wizard_apply_handler(sorcery, otw, category)) {
 				ast_log(LOG_ERROR, "Unable to create objects for wizard '%s'\n", id);

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13510
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: I7b3256983ddfaa2138d3de92a444a53b5193a4e1
Gerrit-Change-Number: 13510
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200107/86ae57d5/attachment.html>


More information about the asterisk-code-review mailing list