[asterisk-commits] rmudgett: branch group/CCSS_Monitor_Restructure r244329 - /team/group/CCSS_Mo...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 2 12:28:56 CST 2010


Author: rmudgett
Date: Tue Feb  2 12:28:54 2010
New Revision: 244329

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=244329
Log:
Miscellaneous fixes.

*  Fix crash because cc_monitor_failed() could not find the core_id.  The
core instance was already deleted because CC had successfully completed.
*  cc_build_payload() needs to actually save the private_data.  The system
is kind of crashy otherwise.  Not to mention memory and reference leaks.
*  Fix CLI "cc report status" format.  A new line was accidentally
deleted.

Modified:
    team/group/CCSS_Monitor_Restructure/main/ccss.c

Modified: team/group/CCSS_Monitor_Restructure/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS_Monitor_Restructure/main/ccss.c?view=diff&rev=244329&r1=244328&r2=244329
==============================================================================
--- team/group/CCSS_Monitor_Restructure/main/ccss.c (original)
+++ team/group/CCSS_Monitor_Restructure/main/ccss.c Tue Feb  2 12:28:54 2010
@@ -148,10 +148,10 @@
 	 * 2) Alignment padding issues for the element types.
 	 */
 	const char *monitor_type;
+	void *private_data;
 	enum ast_cc_service_type service;
 	struct ast_cc_config_params config_params;
 	int parent_interface_id;
-	void *private_data;
 	char device_name[AST_CHANNEL_NAME];
 	char dialable_name[AST_CHANNEL_NAME];
 };
@@ -3019,8 +3019,20 @@
 static int cc_monitor_failed(void *data)
 {
 	struct ast_cc_monitor_failure_data *failure_data = data;
-	struct cc_core_instance *core_instance = find_cc_core_instance(failure_data->core_id);
+	struct cc_core_instance *core_instance;
 	struct ast_cc_monitor *monitor_iter;
+
+	core_instance = find_cc_core_instance(failure_data->core_id);
+	if (!core_instance) {
+		/* Core instance no longer exists or invalid core_id. */
+		ast_log_dynamic_level(cc_logger_level,
+			"Could not find core instance %d for device %s '%s'\n",
+			failure_data->core_id, failure_data->device_name, failure_data->debug);
+		ast_free((char *) failure_data->device_name);
+		ast_free((char *) failure_data->debug);
+		ast_free(failure_data);
+		return -1;
+	}
 
 	AST_DLLIST_LOCK(core_instance->monitors);
 	AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN(core_instance->monitors, monitor_iter, next) {
@@ -3041,10 +3053,11 @@
 		ast_cc_failed(core_instance->core_id, "All monitors have failed\n");
 	}
 	AST_DLLIST_UNLOCK(core_instance->monitors);
+	cc_unref(core_instance, "Finished with core_instance in cc_monitor_failed\n");
+
 	ast_free((char *) failure_data->device_name);
 	ast_free((char *) failure_data->debug);
 	ast_free(failure_data);
-	cc_unref(core_instance, "Finished with core_instance in cc_monitor_failed\n");
 	return 0;
 }
 
@@ -3239,6 +3252,7 @@
 	ast_channel_unlock(chan);
 
 	payload->monitor_type = monitor_type;
+	payload->private_data = private_data;
 	payload->service = service;
 	ast_cc_copy_config_params(&payload->config_params, cc_params);
 	payload->parent_interface_id = dial_parent_id;
@@ -3494,6 +3508,7 @@
 		if (monitor->interface->monitor_class == AST_CC_DEVICE_MONITOR) {
 			ast_cli(fd, "(%s)", cc_service_to_string(monitor->service_offered));
 		}
+		ast_cli(fd, "\n");
 	}
 
 	cc_cli_print_monitor_stats(AST_DLLIST_NEXT(monitor, next), fd, monitor->id);




More information about the asterisk-commits mailing list