[asterisk-commits] mmichelson: branch group/CCSS_Monitor_Restructure r243055 - /team/group/CCSS_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 25 16:46:33 CST 2010


Author: mmichelson
Date: Mon Jan 25 16:46:29 2010
New Revision: 243055

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=243055
Log:
Tweak a few things I found during testing.

* Fix a crash by not freeing a string prematurely. Changed this
to actually just use a monitor pointer instead for simplicity.

* Actually add the generic monitor instance to its list when we
create it.

* Be sure to call ast_cc_monitor_request_acknowledged when we
successfully request CC.


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=243055&r1=243054&r2=243055
==============================================================================
--- team/group/CCSS_Monitor_Restructure/main/ccss.c (original)
+++ team/group/CCSS_Monitor_Restructure/main/ccss.c Mon Jan 25 16:46:29 2010
@@ -906,14 +906,8 @@
 static struct generic_monitor_instance_list *create_new_generic_list(struct ast_cc_monitor *monitor)
 {
 	struct generic_monitor_instance_list *generic_list = ao2_alloc(sizeof(*generic_list), generic_monitor_instance_list_destructor);
-	char *monitor_name_copy = ast_strdup(monitor->interface->name);
 
 	if (!generic_list) {
-		return NULL;
-	}
-	
-	if (!monitor_name_copy) {
-		cc_unref(generic_list, "Failed to make monitor name copy in create_new_generic_list");
 		return NULL;
 	}
 
@@ -923,7 +917,7 @@
 	}
 
 	if (!(generic_list->sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE, generic_monitor_devstate_cb,
-				"Requesting CC", monitor_name_copy, AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, 
+				"Requesting CC", monitor, AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, 
 				monitor->interface->name, AST_EVENT_IE_END))) {
 		cc_unref(generic_list, "Failed to subscribe to device state");
 		return NULL;
@@ -934,15 +928,16 @@
 }
 
 struct generic_tp_cb_data {
-	char *monitor_name;
+	struct ast_cc_monitor *monitor;
 	enum ast_device_state new_state;
 };
 
 static int generic_monitor_devstate_tp_cb(void *data)
 {
 	struct generic_tp_cb_data *gtcd = data;
-	char *monitor_name = gtcd->monitor_name;
+	struct ast_cc_monitor *monitor = gtcd->monitor;
 	enum ast_device_state new_state = gtcd->new_state;
+	const char *monitor_name = monitor->interface->name;
 	struct generic_monitor_instance_list *generic_list;
 	struct generic_monitor_instance *generic_instance;
 
@@ -951,14 +946,12 @@
 		 * time between subscribing to its device state and the time this executes.
 		 * Not really a big deal.
 		 */
-		ast_free(monitor_name);
 		ast_free(gtcd);
 		return 0;
 	}
 
 	if (generic_list->current_state == new_state) {
 		/* The device state hasn't actually changed, so we don't really care */
-		ast_free(monitor_name);
 		ast_free(gtcd);
 		cc_unref(generic_list, "Kill reference of generic list in devstate taskprocessor callback");
 		return 0;
@@ -975,7 +968,6 @@
 		}	
 	}
 	cc_unref(generic_list, "Kill reference of generic list in devstate taskprocessor callback");
-	ast_free(monitor_name);
 	ast_free(gtcd);
 	return 0;
 }
@@ -987,19 +979,17 @@
 	 * so that all monitor operations can be serialized. Locks?! We don't need
 	 * no steenkin' locks!
 	 */
-	char *monitor_name = userdata;
+	struct ast_cc_monitor *monitor = userdata;
 	struct generic_tp_cb_data *gtcd = ast_calloc(1, sizeof(*gtcd));
 
 	if (!gtcd) {
-		ast_free(monitor_name);
 		return;
 	}
 
-	gtcd->monitor_name = monitor_name;
+	gtcd->monitor = monitor;
 	gtcd->new_state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
 
 	if (ast_taskprocessor_push(cc_core_taskprocessor, generic_monitor_devstate_tp_cb, gtcd)) {
-		ast_free(gtcd->monitor_name);
 		ast_free(gtcd);
 	}
 }
@@ -1049,11 +1039,13 @@
 		return -1;
 	}
 	generic_instance->core_id = monitor->core_id;
+	AST_LIST_INSERT_TAIL(&generic_list->list, generic_instance, next);
 	when = service == AST_CC_CCBS ? ast_get_ccbs_available_timer(monitor->interface->config_params) :
 		ast_get_ccnr_available_timer(monitor->interface->config_params);
 
 	*available_timer_id = ast_sched_thread_add(cc_sched_thread, when * 1000,
 			ast_cc_available_timer_expire, cc_ref(monitor, "Give the scheduler a monitor reference"));
+	ast_cc_monitor_request_acked(monitor->core_id, "Generic monitor subscribed to device state.\n");
 	cc_unref(generic_list, "Finished with monitor instance reference in request cc callback");
 	return 0;
 }




More information about the asterisk-commits mailing list