[Asterisk-code-review] Unused realtime MOH classes not purged on 'moh reload' (asterisk[13])

Joshua Colp asteriskteam at digium.com
Thu Apr 6 04:31:34 CDT 2017


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/5319 )

Change subject: Unused realtime MOH classes not purged on 'moh reload'
......................................................................


Unused realtime MOH classes not purged on 'moh reload'

Purge Realtime MOH classes on 'moh reload' even when musiconhold.conf
hasn't changed.

ASTERISK-25974 #close

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

Approvals:
  Mark Michelson: Looks good to me, approved
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 6b0f00a..4f8c735 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -154,6 +154,7 @@
 
 /* Custom astobj2 flag */
 #define MOH_NOTDELETED          (1 << 30)       /*!< Find only records that aren't deleted? */
+#define MOH_REALTIME          (1 << 31)       /*!< Find only records that are realtime */
 
 static struct ast_flags global_flags[1] = {{0}};        /*!< global MOH_ flags */
 
@@ -1683,7 +1684,9 @@
 {
 	struct mohclass *class = obj;
 
-	class->delete = 1;
+	if ( ((flags & MOH_REALTIME) && class->realtime) || !(flags & MOH_REALTIME) ) {
+		class->delete = 1;
+	}
 
 	return 0;
 }
@@ -1699,22 +1702,27 @@
 {
 	struct ast_config *cfg;
 	struct ast_variable *var;
-	struct mohclass *class;	
+	struct mohclass *class;
 	char *cat;
 	int numclasses = 0;
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 
 	cfg = ast_config_load("musiconhold.conf", config_flags);
 
+	if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
+		if (ast_check_realtime("musiconhold") && reload) {
+			ao2_t_callback(mohclasses, OBJ_NODATA | MOH_REALTIME, moh_class_mark, NULL, "Mark realtime classes for deletion");
+			ao2_t_callback(mohclasses, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, moh_classes_delete_marked, NULL, "Purge marked classes");
+		}
+		moh_rescan_files();
+		return 0;
+	}
+
 	if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
 		if (ast_check_realtime("musiconhold") && reload) {
 			ao2_t_callback(mohclasses, OBJ_NODATA, moh_class_mark, NULL, "Mark deleted classes");
 			ao2_t_callback(mohclasses, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, moh_classes_delete_marked, NULL, "Purge marked classes");
 		}
-		return 0;
-	}
-	if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
-		moh_rescan_files();
 		return 0;
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/5319
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I42c78ea76528473a656f204595956c9eedcf3246
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Daniel Journo <dan at keshercommunications.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>



More information about the asterisk-code-review mailing list