[Asterisk-code-review] res_musiconhold: Load all realtime entries, not just the first (asterisk[17])

Friendly Automation asteriskteam at digium.com
Wed Sep 30 08:00:56 CDT 2020


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

Change subject: res_musiconhold: Load all realtime entries, not just the first
......................................................................

res_musiconhold: Load all realtime entries, not just the first

ASTERISK-29099

Change-Id: I45636679c0fb5a5f59114c8741626631a604e8a6
---
M res/res_musiconhold.c
1 file changed, 9 insertions(+), 6 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Sean Bright: 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_musiconhold.c b/res/res_musiconhold.c
index 8d1ab2a..db7dde7 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -1609,19 +1609,22 @@
 	if (var) {
 		const char *mode = ast_variable_find_in_list(var, "mode");
 		if (ast_strings_equal(mode, "playlist")) {
-			struct ast_variable *entries = ast_load_realtime("musiconhold_entry", "name", name, SENTINEL);
-			struct ast_variable *cur = entries;
+			struct ast_config *entries = ast_load_realtime_multientry("musiconhold_entry", "position >=", "0", "name", name, SENTINEL);
+			char *category = NULL;
 			size_t entry_count = 0;
-			for (; cur; cur = cur->next) {
-				if (!strcmp(cur->name, "entry")) {
-					struct ast_variable *dup = ast_variable_new(cur->name, cur->value, "");
+
+			while ((category = ast_category_browse(entries, category))) {
+				const char *entry = ast_variable_retrieve(entries, category, "entry");
+
+				if (entry) {
+					struct ast_variable *dup = ast_variable_new("entry", entry, "");
 					if (dup) {
 						entry_count++;
 						ast_variable_list_append(&var, dup);
 					}
 				}
 			}
-			ast_variables_destroy(entries);
+			ast_config_destroy(entries);
 
 			if (entry_count == 0) {
 				/* Behave as though this class doesn't exist */

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

Gerrit-Project: asterisk
Gerrit-Branch: 17
Gerrit-Change-Id: I45636679c0fb5a5f59114c8741626631a604e8a6
Gerrit-Change-Number: 15008
Gerrit-PatchSet: 2
Gerrit-Owner: lvl <digium at lvlconsultancy.nl>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200930/ca8af746/attachment.html>


More information about the asterisk-code-review mailing list