[asterisk-commits] rmudgett: branch group/CCSS_Monitor_Restructure r244504 - in /team/group/CCSS...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Feb 3 10:45:47 CST 2010
Author: rmudgett
Date: Wed Feb 3 10:45:43 2010
New Revision: 244504
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=244504
Log:
Check exception paths for memory and reference leaks in CCSS.
* Fixed several memory and reference leaks in exception paths.
* ast_cc_agent_set_interfaces_chanvar() did not need the agent parameter.
Modified:
team/group/CCSS_Monitor_Restructure/channels/chan_sip.c
team/group/CCSS_Monitor_Restructure/channels/sig_pri.c
team/group/CCSS_Monitor_Restructure/include/asterisk/ccss.h
team/group/CCSS_Monitor_Restructure/main/ccss.c
Modified: team/group/CCSS_Monitor_Restructure/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS_Monitor_Restructure/channels/chan_sip.c?view=diff&rev=244504&r1=244503&r2=244504
==============================================================================
--- team/group/CCSS_Monitor_Restructure/channels/chan_sip.c (original)
+++ team/group/CCSS_Monitor_Restructure/channels/chan_sip.c Wed Feb 3 10:45:43 2010
@@ -22711,10 +22711,8 @@
/* First invitation - create the channel */
c = sip_new(p, AST_STATE_DOWN, S_OR(p->peername, NULL), NULL);
if (cc_recall_core_id != -1) {
- char full_extension[SIPBUFSIZE];
- snprintf(full_extension, sizeof(full_extension) - 1, "%s@%s", p->exten, p->context);
ast_setup_cc_recall_datastore(c, cc_recall_core_id);
- ast_set_cc_interfaces_chanvar(c, full_extension);
+ ast_cc_agent_set_interfaces_chanvar(c);
}
*recount = 1;
Modified: team/group/CCSS_Monitor_Restructure/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS_Monitor_Restructure/channels/sig_pri.c?view=diff&rev=244504&r1=244503&r2=244504
==============================================================================
--- team/group/CCSS_Monitor_Restructure/channels/sig_pri.c (original)
+++ team/group/CCSS_Monitor_Restructure/channels/sig_pri.c Wed Feb 3 10:45:43 2010
@@ -2334,7 +2334,7 @@
agent = sig_pri_find_cc_agent_by_cc_id(pri, subcmd->u.cc_call.cc_id);
if (agent) {
ast_setup_cc_recall_datastore(owner, agent->core_id);
- ast_cc_agent_set_interfaces_chanvar(owner, agent);
+ ast_cc_agent_set_interfaces_chanvar(owner);
ast_cc_agent_recalling(agent->core_id,
"ISDN caller is attempting recall");
ao2_ref(agent, -1);
Modified: team/group/CCSS_Monitor_Restructure/include/asterisk/ccss.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS_Monitor_Restructure/include/asterisk/ccss.h?view=diff&rev=244504&r1=244503&r2=244504
==============================================================================
--- team/group/CCSS_Monitor_Restructure/include/asterisk/ccss.h (original)
+++ team/group/CCSS_Monitor_Restructure/include/asterisk/ccss.h Wed Feb 3 10:45:43 2010
@@ -1381,8 +1381,7 @@
/*!
* \since 1.8
- * \brief Set the CC_INTERFACES channel variable for a channel using an
- * agent as input
+ * \brief Set the first level CC_INTERFACES channel variable for a channel.
*
* \note
* Implementers of protocol-specific CC agents should call this function after
@@ -1393,9 +1392,8 @@
* called back for a specific PBX instance.
*
* \param chan The channel to set the CC_INTERFACES variable on
- * \param agent The agent in use for the CC transaction
- */
-int ast_cc_agent_set_interfaces_chanvar(struct ast_channel *chan, struct ast_cc_agent *agent);
+ */
+int ast_cc_agent_set_interfaces_chanvar(struct ast_channel *chan);
/*!
* \since 1.8
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=244504&r1=244503&r2=244504
==============================================================================
--- team/group/CCSS_Monitor_Restructure/main/ccss.c (original)
+++ team/group/CCSS_Monitor_Restructure/main/ccss.c Wed Feb 3 10:45:43 2010
@@ -1069,6 +1069,7 @@
}
if (!(gen_mon_pvt->device_name = ast_strdup(monitor->interface->name))) {
+ ast_free(gen_mon_pvt);
return -1;
}
@@ -1096,6 +1097,11 @@
*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"));
+ if (*available_timer_id == -1) {
+ cc_unref(monitor, "Failed to schedule available timer. (monitor)");
+ cc_unref(generic_list, "Failed to schedule available timer. (generic_list)");
+ return -1;
+ }
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;
@@ -1216,6 +1222,7 @@
* below if the list traversal should complete without finding an entry.
*/
ast_free((char *)gen_mon_pvt->device_name);
+ ast_free(gen_mon_pvt);
return;
}
@@ -1621,15 +1628,15 @@
}
if (!(monitor->dialable_name = ast_strdup(dialable_name))) {
+ cc_unref(monitor, "Failed to copy dialable name. Unref monitor");
cc_unref(cc_interface, "Failed to copy dialable name");
- cc_unref(monitor, "Failed to copy dialable name. Unref monitor");
call_destructor_with_no_monitor(cc_data->monitor_type, cc_data->private_data);
return NULL;
}
if (!(monitor->callbacks = find_monitor_callbacks(cc_data->monitor_type))) {
- ao2_t_ref(cc_interface, -1, "Failed to find monitor callbacks\n");
cc_unref(monitor, "Failed to find monitor callbacks. Unref monitor");
+ cc_unref(cc_interface, "Failed to find monitor callbacks");
call_destructor_with_no_monitor(cc_data->monitor_type, cc_data->private_data);
return NULL;
}
@@ -1745,8 +1752,8 @@
}
AST_DLLIST_LOCK(cc_interfaces->interface_tree);
+ cc_ref(monitor, "Interface tree's reference to the monitor");
AST_DLLIST_INSERT_TAIL(cc_interfaces->interface_tree, monitor, next);
- cc_ref(monitor, "Interface tree's reference to the monitor");
AST_DLLIST_UNLOCK(cc_interfaces->interface_tree);
manager_event(EVENT_FLAG_CC, "CCAvailable",
@@ -1785,9 +1792,16 @@
struct ast_datastore *cc_interfaces_datastore;
struct dialed_cc_interfaces *interfaces;
struct ast_cc_monitor *monitor;
+ struct ast_cc_config_params *cc_params;
+
ast_channel_lock(chan);
- if (ast_get_cc_agent_policy(ast_channel_get_cc_config_params(chan)) == AST_CC_AGENT_NEVER) {
+ cc_params = ast_channel_get_cc_config_params(chan);
+ if (!cc_params) {
+ ast_channel_unlock(chan);
+ return -1;
+ }
+ if (ast_get_cc_agent_policy(cc_params) == AST_CC_AGENT_NEVER) {
/* We can't offer CC to this caller anyway, so don't bother with CC on this call
*/
*ignore_cc = 1;
@@ -1821,8 +1835,8 @@
*/
monitor->dialable_name = ast_strdup(interfaces->current_extension_dialable_name);
AST_DLLIST_LOCK(interfaces->interface_tree);
+ cc_ref(monitor, "Interface tree's reference to the monitor");
AST_DLLIST_INSERT_TAIL(interfaces->interface_tree, monitor, next);
- cc_ref(monitor, "Interface tree's reference to the monitor");
AST_DLLIST_UNLOCK(interfaces->interface_tree);
interfaces->dial_parent_id = monitor->id;
cc_unref(monitor, "Unref monitor's allocation reference");
@@ -1862,7 +1876,8 @@
return data.count;
}
-static void kill_duplicate_offers(char *caller) {
+static void kill_duplicate_offers(char *caller)
+{
unsigned long match_flags = MATCH_NO_REQUEST;
ao2_t_callback_data(cc_core_instances, OBJ_UNLINK | OBJ_NODATA, match_agent, caller, &match_flags, "Killing duplicate offers");
}
@@ -2168,7 +2183,7 @@
* function to do so.
*/
ast_setup_cc_recall_datastore(chan, agent->core_id);
- ast_cc_agent_set_interfaces_chanvar(chan, agent);
+ ast_cc_agent_set_interfaces_chanvar(chan);
ast_copy_string(chan->exten, generic_pvt->exten, sizeof(chan->exten));
ast_copy_string(chan->context, generic_pvt->context, sizeof(chan->context));
@@ -2415,7 +2430,6 @@
return -1;
}
core_instance->agent->callbacks->stop_offer_timer(core_instance->agent);
- /* It doesn't matter what service we state for the root monitor, so we just use AST_CC_NONE */
request_cc(core_instance);
manager_event(EVENT_FLAG_CC, "CCRequested",
"CoreID: %d\r\n"
@@ -2801,12 +2815,13 @@
break;
}
}
+ cc_ref(monitor_iter, "Hand the requester of the monitor a reference");
AST_DLLIST_UNLOCK(core_instance->monitors);
cc_unref(core_instance, "Done with core instance ref in ast_cc_get_monitor_by_recall_core_id");
- return cc_ref(monitor_iter, "Hand the requester of the monitor a reference");
-}
-
-int ast_cc_agent_set_interfaces_chanvar(struct ast_channel *chan, struct ast_cc_agent *agent)
+ return monitor_iter;
+}
+
+int ast_cc_agent_set_interfaces_chanvar(struct ast_channel *chan)
{
struct ast_datastore *recall_datastore;
struct ast_cc_interface_tree *interface_tree;
@@ -2823,10 +2838,10 @@
ast_free(var_value);
return -1;
}
-
recall_data = recall_datastore->data;
interface_tree = cc_ref(recall_data->interface_tree, "Getting ref of recall interface tree");
ast_channel_unlock(chan);
+
AST_DLLIST_LOCK(interface_tree);
monitor_iter = AST_DLLIST_FIRST(interface_tree);
top_level_id = monitor_iter->id;
@@ -2865,7 +2880,6 @@
ast_free(var_value);
return -1;
}
-
recall_data = recall_datastore->data;
interface_tree = cc_ref(recall_data->interface_tree, "Get reference to recall data interface tree");
ast_channel_unlock(chan);
@@ -2900,6 +2914,7 @@
}
}
AST_DLLIST_UNLOCK(interface_tree);
+
pbx_builtin_setvar_helper(chan, "CC_INTERFACES", ast_str_buffer(var_value));
ast_log_dynamic_level(cc_logger_level, "CC_INTERFACES set to %s\n", ast_str_buffer(var_value));
ast_free(var_value);
@@ -3404,6 +3419,7 @@
if (!ast_cc_request_is_within_limits()) {
ast_log_dynamic_level(cc_logger_level, "CallCompletionRequest failed. Too many requests in the system\n");
ast_cc_failed(core_instance->core_id, "Too many CC requests\n");
+ cc_unref(core_instance, "Unref core_instance since too many CC requests");
return -1;
}
More information about the asterisk-commits
mailing list