[asterisk-commits] mmichelson: branch group/CCSS r218101 - /team/group/CCSS/main/ccss.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 11 15:45:01 CDT 2009


Author: mmichelson
Date: Fri Sep 11 15:44:58 2009
New Revision: 218101

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=218101
Log:
Fix some refcount errors


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

Modified: team/group/CCSS/main/ccss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=218101&r1=218100&r2=218101
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Fri Sep 11 15:44:58 2009
@@ -1039,6 +1039,7 @@
 	}
 
 	if (monitor->monitor_class == AST_CC_ROOT_MONITOR) {
+		ao2_t_ref(core_instance, -1, "Unref core_instance from earlier ao2_find")
 		ast_cc_request_state_change(CC_CALLEE_READY, core_id, "Device being monitored has become available");
 		return 0;
 	}
@@ -1061,6 +1062,7 @@
 	}
 
 	pass_availability_up(link->parent, core_id);
+	ao2_t_ref(core_instance, -1, "Unref core_instance from earlier ao2_find");
 
 	return 0;
 }
@@ -1275,6 +1277,7 @@
 	struct cc_generic_agent_pvt *generic_pvt;
 	char *dash;
 	unsigned long match_flags;
+	int res;
 
 	ast_copy_string(interface, chan->name, sizeof(interface));
 	if ((dash = strrchr(interface, '-'))) {
@@ -1289,13 +1292,16 @@
 
 	if (strcmp(core_instance->agent->callbacks->type, "generic")) {
 		ast_log(LOG_NOTICE, "CallCompletionRequest is only for generic agent types.\n");
+		ao2_t_ref(core_instance, -1, "Unref core_instance since CallCompletionRequest was called with native agent");
 		return -1;
 	}
 
 	generic_pvt = core_instance->agent->private_data;
 
 	ast_sched_thread_del(cc_sched_thread, generic_pvt->offer_timer_id);
-	return ast_cc_request_state_change(CC_CALLER_REQUESTED, core_instance->core_id, "CallCompletionRequest called");
+	res = ast_cc_request_state_change(CC_CALLER_REQUESTED, core_instance->core_id, "CallCompletionRequest called");
+	ao2_t_ref(core_instance, -1, "Done with CallCompletionRequest");
+	return res;
 }
 
 static char *cccancel_app = "CallCompletionCancel";
@@ -1306,6 +1312,7 @@
 	char interface[AST_CHANNEL_NAME];
 	char *dash;
 	unsigned long match_flags;
+	int res;
 
 	ast_copy_string(interface, chan->name, sizeof(interface));
 	if ((dash = strrchr(interface, '-'))) {
@@ -1323,9 +1330,9 @@
 		ao2_t_ref(core_instance, -1, "Unref core instance found during CallCompletionCancel");
 		return -1;
 	}
-	ast_cc_request_state_change(CC_FAILED, core_instance->core_id, "Call completion request Cancelled");
+	res = ast_cc_request_state_change(CC_FAILED, core_instance->core_id, "Call completion request Cancelled");
 	ao2_t_ref(core_instance, -1, "Unref core instance found during CallCompletionCancel");
-	return 0;
+	return res;
 }
 
 static int cc_extension_monitor_init(struct ast_cc_monitor *monitor, const int core_id);




More information about the asterisk-commits mailing list