[asterisk-commits] mmichelson: branch group/CCSS r214079 - /team/group/CCSS/main/ccss.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Aug 25 15:05:53 CDT 2009
Author: mmichelson
Date: Tue Aug 25 15:05:50 2009
New Revision: 214079
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=214079
Log:
Function to initialize a core_cc_pending_offer
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=214079&r1=214078&r2=214079
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Tue Aug 25 15:05:50 2009
@@ -393,6 +393,17 @@
*/
int core_id;
/*!
+ * The reference-counted "tree" of interfaces dialed by the
+ * caller. In reality this is a linked list which has fields
+ * which help to "point" to where a node's parent is in the
+ * list.
+ */
+ struct ast_cc_interface_tree *called_tree;
+ /*!
+ * A handle to the agent for this particular CC offer.
+ */
+ struct ast_cc_agent *agent;
+ /*!
* Text identifying the caller. Tentatively, this is just the
* device name of the calling channel. However, this may need
* to be modified to include CID information or something to
@@ -401,18 +412,7 @@
* so using just the device name as an identifier is not specific
* enough.
*/
- const char *caller;
- /*!
- * The reference-counted "tree" of interfaces dialed by the
- * caller. In reality this is a linked list which has fields
- * which help to "point" to where a node's parent is in the
- * list.
- */
- struct ast_cc_interface_tree *called_tree;
- /*!
- * A handle to the agent for this particular CC offer.
- */
- struct ast_cc_agent *agent;
+ char caller[1];
};
static int pending_offer_hash_fn(const void *obj, const int flags)
@@ -450,10 +450,36 @@
ao2_callback(pending_cc_offers, OBJ_UNLINK | OBJ_NODATA, match_caller, caller);
}
+static void pending_offer_destructor(void *obj)
+{
+ struct core_pending_cc_offer *pending_offer = obj;
+ ao2_ref(pending_offer->called_tree, -1);
+}
+
+static struct core_pending_cc_offer *pending_cc_offer_init(const char *caller, const size_t caller_len,
+ struct ast_cc_interface_tree *called_tree)
+{
+ struct core_pending_cc_offer *pending_offer = ao2_alloc(sizeof(*pending_offer) + caller_len,
+ pending_offer_destructor);
+
+ if (!pending_offer) {
+ return NULL;
+ }
+
+ strcpy(pending_offer->caller, caller);
+ pending_offer->core_id = ast_atomic_fetchadd_int(&core_id_counter, +1);
+ ao2_ref(called_tree, +1);
+ pending_offer->called_tree = called_tree;
+ /* TODO Allocate agent and assign it here */
+ ao2_link(pending_cc_offers, pending_offer);
+ return pending_offer;
+}
+
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;
if (dash) {
*dash = '\0';
@@ -465,6 +491,9 @@
kill_duplicate_offers(caller);
/* Next, we need to allocate the structure we will use to store the tree. */
+ if (!(pending_offer = pending_cc_offer_init(caller, strlen(caller), called_tree))) {
+ return -1;
+ }
/* Next, we need to store this new tree in a container */
More information about the asterisk-commits
mailing list