[asterisk-commits] mmichelson: branch group/CCSS r214193 - in /team/group/CCSS: include/asterisk...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Aug 26 10:56:18 CDT 2009
Author: mmichelson
Date: Wed Aug 26 10:56:15 2009
New Revision: 214193
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=214193
Log:
Progress towards starting up the core.
It compiles. That's all I'm going to say. I need
to define the agent more fully. I'm pretty sure
it'll end up being refcounted since, especially
with native agents, multiple threads will need
to refer to a single agent.
Modified:
team/group/CCSS/include/asterisk/ccss.h
team/group/CCSS/main/ccss.c
Modified: team/group/CCSS/include/asterisk/ccss.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/include/asterisk/ccss.h?view=diff&rev=214193&r1=214192&r2=214193
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Wed Aug 26 10:56:15 2009
@@ -577,9 +577,8 @@
* that after this function is called, it is perfectly acceptable
* for app_dial to continue adding interfaces to the called_tree.
*
- * This function currently will add a reference to the called_tree
- * so that it will not be deleted once the initial call has been
- * hung up.
+ * This function currently will add the called tree to a container
+ * of pending CC offers, so that they may be saved for future use.
*
* TODO: This function also needs to allocate the agent structure
* for the caller's side and start the core state machine in the
Modified: team/group/CCSS/main/ccss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=214193&r1=214192&r2=214193
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Wed Aug 26 10:56:15 2009
@@ -411,6 +411,27 @@
char caller[1];
};
+struct cc_core_instance {
+ /*!
+ * unique identifier for this instance of the CC core. There will
+ * be a corresponding core_pending_cc_offer structure with the
+ * same core_id, up until this instance of the core creates
+ * a monitor structure
+ */
+ int core_id;
+ /*!
+ * The CC agent in use for this call
+ */
+ struct ast_cc_agent *agent;
+ /*!
+ * Reference to the root of the monitor tree
+ * commented out until struct is actually defined.
+ */
+ /*
+ struct ast_cc_monitor *monitor;
+ */
+};
+
static int pending_offer_hash_fn(const void *obj, const int flags)
{
const struct core_pending_cc_offer *pending_offer = obj;
@@ -450,6 +471,7 @@
{
struct core_pending_cc_offer *pending_offer = obj;
ao2_ref(pending_offer->called_tree, -1);
+ /*astobj2 code will free the pending offer */
}
static struct core_pending_cc_offer *pending_cc_offer_init(const char *caller, const size_t caller_len,
@@ -470,19 +492,35 @@
return pending_offer;
}
+static struct ast_cc_agent *cc_agent_init(struct ast_channel *caller_chan) {
+ struct ast_cc_agent *agent;
+
+ if (!(agent = ast_calloc(1, sizeof(*agent)))) {
+ return NULL;
+ }
+ return agent;
+}
+
+static void cc_core_instance_destructor(void *data)
+{
+ struct cc_core_instance *core_instance = data;
+ ast_free(core_instance->agent);
+}
+
int ast_cc_core_init_instance(struct ast_channel *caller_chan, struct ast_cc_interface_tree *called_tree)
{
char *caller = ast_strdupa(caller_chan->name);
char *dash = strrchr(caller, '-');
struct core_pending_cc_offer *pending_offer;
-
+ struct cc_core_instance *core_instance;
+
if (dash) {
*dash = '\0';
}
+
/* First, we need to kill off other pending CC offers to caller. If the caller is going
* to request a CC service, it may only be for the latest call he made.
*/
-
kill_duplicate_offers(caller);
/* Next, we need to allocate the structure we will use to store the tree. */
@@ -490,13 +528,21 @@
return -1;
}
- /* Next, we need to store this new tree in a container */
-
- /* Next, we need to create the agent for this caller */
+ /* Next, we need to create the core instance for this call */
+ if (!(core_instance = ao2_alloc(sizeof(*core_instance), cc_core_instance_destructor))) {
+ ao2_ref(pending_offer, -1);
+ return -1;
+ }
+
+ core_instance->core_id = pending_offer->core_id;
+ if (!(core_instance->agent = cc_agent_init(caller_chan))) {
+ ao2_ref(pending_offer, -1);
+ ao2_ref(core_instance, -1);
+ return -1;
+ }
/* Finally, start the state machine! */
- /*ao2_ref(called_tree, +1);*/
return 0;
}
More information about the asterisk-commits
mailing list