[asterisk-commits] mmichelson: branch group/CCSS r226225 - in /team/group/CCSS: include/asterisk...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Oct 27 17:06:13 CDT 2009
Author: mmichelson
Date: Tue Oct 27 17:06:10 2009
New Revision: 226225
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=226225
Log:
Change ast_setup_cc_recall_datastore to take a core_id instead of an agent.
The change is made for two reasons.
1) This should make it easier for channel drivers to use.
2) This avoids a potential race condition. This function is most likely to
be called in a channel driver monitor thread. Since agents are not refcounted,
it is potentially dangerous to get a pointer to an agent and expect it to stay
valid since the CC thread could destroy the agent out from under the channel
monitor thread. By using the core_id, we can guarantee that the agent is accessed
through a cc_core_instance, which is refcounted, which makes the operation safe.
Modified:
team/group/CCSS/include/asterisk/ccss.h
team/group/CCSS/main/ccss.c
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=226225&r1=226224&r2=226225
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Tue Oct 27 17:06:10 2009
@@ -1019,7 +1019,7 @@
* be able to have the core do this automatically, it just cannot be done given
* the current architecture.
*/
-int ast_setup_cc_recall_datastore(struct ast_channel *chan, struct ast_cc_agent *agent);
+int ast_setup_cc_recall_datastore(struct ast_channel *chan, const int core_id);
/*!
* \since 1.6.4
Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=226225&r1=226224&r2=226225
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Tue Oct 27 17:06:10 2009
@@ -1979,7 +1979,7 @@
* the core do it automatically, but alas I cannot. Instead, I will provide a public
* function to do so.
*/
- ast_setup_cc_recall_datastore(chan, agent);
+ ast_setup_cc_recall_datastore(chan, agent->core_id);
ast_set_cc_interfaces_chanvar(chan, full_extension);
/* Now we can bust apart the outbound name so that the PBX will run. */
exten = full_extension;
@@ -2721,10 +2721,12 @@
.destroy = cc_recall_ds_destroy,
};
-int ast_setup_cc_recall_datastore(struct ast_channel *chan, struct ast_cc_agent *agent)
+int ast_setup_cc_recall_datastore(struct ast_channel *chan, const int core_id)
{
struct ast_datastore *recall_datastore = ast_datastore_alloc(&recall_ds_info, NULL);
struct cc_recall_ds_data *recall_data;
+ struct cc_core_instance *core_instance;
+ struct cc_core_instance finder = { .core_id = core_id };
if (!recall_datastore) {
return -1;
@@ -2735,13 +2737,22 @@
return -1;
}
- recall_data->interface_tree = cc_ref(agent->interface_tree, "Bump refcount for interface tree for agent");
- recall_data->core_id = agent->core_id;
+ if (!(core_instance = ao2_t_find(cc_core_instances, &finder, OBJ_POINTER,
+ "Find core_instance to set up recall datastore"))) {
+ ast_free(recall_data);
+ ast_datastore_free(recall_datastore);
+ return -1;
+ }
+
+ recall_data->interface_tree = cc_ref(core_instance->agent->interface_tree,
+ "Bump refcount for interface tree for agent");
+ recall_data->core_id = core_id;
recall_datastore->data = recall_data;
recall_datastore->inheritance = DATASTORE_INHERIT_FOREVER;
ast_channel_lock(chan);
ast_channel_datastore_add(chan, recall_datastore);
ast_channel_unlock(chan);
+ cc_unref(core_instance, "Recall datastore set up. No need for core_instance ref");
return 0;
}
More information about the asterisk-commits
mailing list