[asterisk-commits] rmudgett: branch group/CCSS r240269 - in /team/group/CCSS: channels/ include/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jan 14 16:32:13 CST 2010
Author: rmudgett
Date: Thu Jan 14 16:32:11 2010
New Revision: 240269
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=240269
Log:
More CCSS agent constructor failure fixes.
* Changed the agent object agent_destroy() callback to only call the
agent destructor callback. The destructor callback must stop the offer
timer if it needs to do so.
* The agent destructor callback must check to see if the private_data
pointer is NULL. The agent constructor may have failed.
* Fixed a double free of the agent config parameters if the agent init
callback failed.
Modified:
team/group/CCSS/channels/chan_sip.c
team/group/CCSS/include/asterisk/ccss.h
team/group/CCSS/main/ccss.c
Modified: team/group/CCSS/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/chan_sip.c?view=diff&rev=240269&r1=240268&r2=240269
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Thu Jan 14 16:32:11 2010
@@ -3547,9 +3547,12 @@
{
struct sip_cc_agent_pvt *agent_pvt = agent->private_data;
- if (agent_pvt->offer_timer_id != -1) {
- AST_SCHED_DEL(sched, agent_pvt->offer_timer_id);
- }
+ if (!agent_pvt) {
+ /* The agent constructor probably failed. */
+ return;
+ }
+
+ sip_cc_agent_stop_offer_timer(agent);
agent_pvt->original_call = dialog_unref(agent_pvt->original_call, "SIP CC agent destructor: Remove ref to original call");
if (agent_pvt->subscribe_pvt) {
sip_pvt_lock(agent_pvt->subscribe_pvt);
Modified: team/group/CCSS/include/asterisk/ccss.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/include/asterisk/ccss.h?view=diff&rev=240269&r1=240268&r2=240269
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Thu Jan 14 16:32:11 2010
@@ -1044,6 +1044,10 @@
* \details
* The core will call this function upon completion
* or failure of CC.
+ *
+ * \note
+ * The agent private_data pointer may be NULL if the agent
+ * constructor failed.
*/
void (*destructor)(struct ast_cc_agent *agent);
};
Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=240269&r1=240268&r2=240269
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Thu Jan 14 16:32:11 2010
@@ -1841,10 +1841,13 @@
ast_assert(callbacks->destructor != NULL);
}
-static void agent_destroy(void *data) {
+static void agent_destroy(void *data)
+{
struct ast_cc_agent *agent = data;
- agent->callbacks->stop_offer_timer(agent);
- agent->callbacks->destructor(agent);
+
+ if (agent->callbacks) {
+ agent->callbacks->destructor(agent);
+ }
agent->interface_tree = cc_unref(agent->interface_tree, "Destroying agent, removing ref to interface tree");
ast_cc_config_params_destroy(agent->cc_params);
}
@@ -1854,29 +1857,37 @@
struct ast_cc_interface_tree *interface_tree)
{
struct ast_cc_agent *agent;
+ struct ast_cc_config_params *cc_params;
if (!(agent = ao2_alloc(sizeof(*agent) + strlen(caller_name), agent_destroy))) {
return NULL;
}
agent->core_id = core_id;
+ strcpy(agent->interface, caller_name);
+ agent->interface_tree = cc_ref(interface_tree, "Agent now has reference to interface tree");
+
+ cc_params = ast_channel_get_cc_config_params(caller_chan);
+ if (!cc_params) {
+ cc_unref(agent, "Could not get channel config params.");
+ return NULL;
+ }
+ if (!(agent->cc_params = ast_cc_config_params_init())) {
+ cc_unref(agent, "Could not init agent config params.");
+ return NULL;
+ }
+ ast_cc_copy_config_params(agent->cc_params, cc_params);
+
if (!(agent->callbacks = find_agent_callbacks(caller_chan))) {
cc_unref(agent, "Could not find agent callbacks.");
return NULL;
}
check_callback_sanity(agent->callbacks);
- if (!(agent->cc_params = ast_cc_config_params_init())) {
- cc_unref(agent, "Could not init agent config params.");
- return NULL;
- }
- strcpy(agent->interface, caller_name);
- ast_cc_copy_config_params(agent->cc_params, ast_channel_get_cc_config_params(caller_chan));
+
if (agent->callbacks->init(agent, caller_chan)) {
- ast_cc_config_params_destroy(agent->cc_params);
cc_unref(agent, "Agent init callback failed.");
return NULL;
}
- agent->interface_tree = cc_ref(interface_tree, "Agent now has reference to interface tree");
ast_log_dynamic_level(cc_logger_level, "Created an agent with core_id %d and caller %s\n", agent->core_id, agent->interface);
return agent;
}
@@ -2101,10 +2112,13 @@
static void cc_generic_agent_destructor(struct ast_cc_agent *agent)
{
struct cc_generic_agent_pvt *agent_pvt = agent->private_data;
+
if (!agent_pvt) {
+ /* The agent constructor probably failed. */
return;
}
+ cc_generic_agent_stop_offer_timer(agent);
if (agent_pvt->sub) {
agent_pvt->sub = ast_event_unsubscribe(agent_pvt->sub);
}
More information about the asterisk-commits
mailing list