<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/6766">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cdr.c: Rename the Party A CDR container.<br><br>* Rename the Party A CDR container from active_cdrs_by_channel to<br>active_cdrs_master.<br><br>* Renamed the support functions associated with active_cdrs_master<br>appropriately.<br><br>ASTERISK-27335<br><br>Change-Id: I6104bb3edc3a0b7243ce502e45e8832b0cff14f7<br>---<br>M main/cdr.c<br>1 file changed, 45 insertions(+), 38 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/cdr.c b/main/cdr.c<br>index ee1bb36..1424607 100644<br>--- a/main/cdr.c<br>+++ b/main/cdr.c<br>@@ -348,8 +348,8 @@<br> AST_MUTEX_DEFINE_STATIC(cdr_pending_lock);<br> static ast_cond_t cdr_pending_cond;<br> <br>-/*! \brief A container of the active CDRs indexed by Party A channel id */<br>-static struct ao2_container *active_cdrs_by_channel;<br>+/*! \brief A container of the active master CDRs indexed by Party A channel uniqueid */<br>+static struct ao2_container *active_cdrs_master;<br> <br> /*! \brief A container of all active CDRs indexed by Party B channel name */<br> static struct ao2_container *active_cdrs_all;<br>@@ -709,7 +709,7 @@<br> struct ast_flags flags; /*!< Flags on the CDR */<br> AST_DECLARE_STRING_FIELDS(<br> AST_STRING_FIELD(linkedid); /*!< Linked ID. Cached here as it may change out from party A, which must be immutable */<br>- AST_STRING_FIELD(uniqueid); /*!< Unique id of party A. Cached here as it is the primary key of this CDR */<br>+ AST_STRING_FIELD(uniqueid); /*!< Unique id of party A. Cached here as it is the master CDR container key */<br> AST_STRING_FIELD(name); /*!< Channel name of party A. Cached here as the party A address may change */<br> AST_STRING_FIELD(bridge); /*!< The bridge the party A happens to be in. */<br> AST_STRING_FIELD(appl); /*!< The last accepted application party A was in */<br>@@ -797,9 +797,12 @@<br> cdr->fn_table->init_function(cdr);<br> }<br> }<br>-/*! \internal<br>- * \brief Hash function for containers of CDRs indexing by Party A uniqueid */<br>-static int cdr_object_channel_hash_fn(const void *obj, const int flags)<br>+<br>+/*!<br>+ * \internal<br>+ * \brief Hash function for master CDR container indexed by Party A uniqueid.<br>+ */<br>+static int cdr_master_hash_fn(const void *obj, const int flags)<br> {<br> const struct cdr_object *cdr;<br> const char *key;<br>@@ -819,10 +822,11 @@<br> return ast_str_case_hash(key);<br> }<br> <br>-/*! \internal<br>- * \brief Comparison function for containers of CDRs indexing by Party A uniqueid<br>+/*!<br>+ * \internal<br>+ * \brief Comparison function for master CDR container indexed by Party A uniqueid.<br> */<br>-static int cdr_object_channel_cmp_fn(void *obj, void *arg, int flags)<br>+static int cdr_master_cmp_fn(void *obj, void *arg, int flags)<br> {<br> struct cdr_object *left = obj;<br> struct cdr_object *right = arg;<br>@@ -1717,7 +1721,7 @@<br> struct cdr_object *cand_cdr_master;<br> struct cdr_object *cand_cdr;<br> <br>- cand_cdr_master = ao2_find(active_cdrs_by_channel, channel_id, OBJ_SEARCH_KEY);<br>+ cand_cdr_master = ao2_find(active_cdrs_master, channel_id, OBJ_SEARCH_KEY);<br> if (!cand_cdr_master) {<br> continue;<br> }<br>@@ -1865,7 +1869,7 @@<br> struct cdr_object *cand_cdr_master;<br> struct cdr_object *cand_cdr;<br> <br>- cand_cdr_master = ao2_find(active_cdrs_by_channel, channel_id, OBJ_SEARCH_KEY);<br>+ cand_cdr_master = ao2_find(active_cdrs_master, channel_id, OBJ_SEARCH_KEY);<br> if (!cand_cdr_master) {<br> continue;<br> }<br>@@ -2088,9 +2092,9 @@<br> <br> /* Figure out who is running this show */<br> if (caller) {<br>- cdr = ao2_find(active_cdrs_by_channel, caller->uniqueid, OBJ_SEARCH_KEY);<br>+ cdr = ao2_find(active_cdrs_master, caller->uniqueid, OBJ_SEARCH_KEY);<br> } else {<br>- cdr = ao2_find(active_cdrs_by_channel, peer->uniqueid, OBJ_SEARCH_KEY);<br>+ cdr = ao2_find(active_cdrs_master, peer->uniqueid, OBJ_SEARCH_KEY);<br> }<br> if (!cdr) {<br> ast_log(AST_LOG_WARNING, "No CDR for channel %s\n", caller ? caller->name : peer->name);<br>@@ -2245,12 +2249,12 @@<br> return;<br> }<br> cdr->is_root = 1;<br>- ao2_link(active_cdrs_by_channel, cdr);<br>+ ao2_link(active_cdrs_master, cdr);<br> } else {<br> const char *uniqueid;<br> <br> uniqueid = new_snapshot ? new_snapshot->uniqueid : old_snapshot->uniqueid;<br>- cdr = ao2_find(active_cdrs_by_channel, uniqueid, OBJ_SEARCH_KEY);<br>+ cdr = ao2_find(active_cdrs_master, uniqueid, OBJ_SEARCH_KEY);<br> }<br> <br> /* Handle Party A */<br>@@ -2290,7 +2294,7 @@<br> ao2_unlock(cdr);<br> <br> cdr_all_unlink(cdr);<br>- ao2_unlink(active_cdrs_by_channel, cdr);<br>+ ao2_unlink(active_cdrs_master, cdr);<br> }<br> <br> /* Handle Party B */<br>@@ -2380,7 +2384,7 @@<br> (unsigned int)stasis_message_timestamp(message)->tv_sec,<br> (unsigned int)stasis_message_timestamp(message)->tv_usec);<br> <br>- cdr = ao2_find(active_cdrs_by_channel, channel->uniqueid, OBJ_SEARCH_KEY);<br>+ cdr = ao2_find(active_cdrs_master, channel->uniqueid, OBJ_SEARCH_KEY);<br> if (!cdr) {<br> ast_log(AST_LOG_WARNING, "No CDR for channel %s\n", channel->name);<br> ast_assert(0);<br>@@ -2515,7 +2519,7 @@<br> while ((channel_id = ao2_iterator_next(&it_channels))) {<br> struct cdr_object *cand_cdr;<br> <br>- cand_cdr = ao2_find(active_cdrs_by_channel, channel_id, OBJ_SEARCH_KEY);<br>+ cand_cdr = ao2_find(active_cdrs_master, channel_id, OBJ_SEARCH_KEY);<br> if (cand_cdr) {<br> bridge_candidate_process(cdr, cand_cdr);<br> ao2_ref(cand_cdr, -1);<br>@@ -2667,7 +2671,7 @@<br> (unsigned int)stasis_message_timestamp(message)->tv_sec,<br> (unsigned int)stasis_message_timestamp(message)->tv_usec);<br> <br>- cdr = ao2_find(active_cdrs_by_channel, channel->uniqueid, OBJ_SEARCH_KEY);<br>+ cdr = ao2_find(active_cdrs_master, channel->uniqueid, OBJ_SEARCH_KEY);<br> if (!cdr) {<br> ast_log(AST_LOG_WARNING, "No CDR for channel %s\n", channel->name);<br> ast_assert(0);<br>@@ -2717,7 +2721,7 @@<br> (unsigned int)stasis_message_timestamp(message)->tv_sec,<br> (unsigned int)stasis_message_timestamp(message)->tv_usec);<br> <br>- cdr = ao2_find(active_cdrs_by_channel, channel->uniqueid, OBJ_SEARCH_KEY);<br>+ cdr = ao2_find(active_cdrs_master, channel->uniqueid, OBJ_SEARCH_KEY);<br> if (!cdr) {<br> ast_log(AST_LOG_WARNING, "No CDR for channel %s\n", channel->name);<br> ast_assert(0);<br>@@ -2890,7 +2894,7 @@<br> return 0;<br> }<br> <br>- active_count = ao2_container_count(active_cdrs_by_channel);<br>+ active_count = ao2_container_count(active_cdrs_master);<br> <br> if (!match->suspended && active_count != 0) {<br> AST_RWLIST_UNLOCK(&be_list);<br>@@ -3103,7 +3107,7 @@<br> }<br> }<br> <br>- it_cdrs = ao2_callback(active_cdrs_by_channel, OBJ_MULTIPLE, cdr_object_select_all_by_name_cb, arg);<br>+ it_cdrs = ao2_callback(active_cdrs_master, OBJ_MULTIPLE, cdr_object_select_all_by_name_cb, arg);<br> if (!it_cdrs) {<br> ast_log(AST_LOG_ERROR, "Unable to find CDR for channel %s\n", channel_name);<br> return -1;<br>@@ -3231,7 +3235,7 @@<br> }<br> <br> param = ast_strdupa(name);<br>- return ao2_callback(active_cdrs_by_channel, 0, cdr_object_get_by_name_cb, param);<br>+ return ao2_callback(active_cdrs_master, 0, cdr_object_get_by_name_cb, param);<br> }<br> <br> int ast_cdr_getvar(const char *channel_name, const char *name, char *value, size_t length)<br>@@ -3877,7 +3881,7 @@<br> struct ao2_iterator it_cdrs;<br> struct cdr_object *cdr;<br> <br>- it_cdrs = ao2_iterator_init(active_cdrs_by_channel, 0);<br>+ it_cdrs = ao2_iterator_init(active_cdrs_master, 0);<br> while ((cdr = ao2_iterator_next(&it_cdrs))) {<br> if (!strncasecmp(a->word, cdr->party_a.snapshot->name, wordlen) &&<br> (++which > a->n)) {<br>@@ -3909,7 +3913,7 @@<br> ast_cli(a->fd, "--------------------------------------------------\n");<br> ast_cli(a->fd, TITLE_STRING, "Channel", "Dst. Channel", "LastApp", "Start", "Answer", "End", "Billsec", "Duration");<br> <br>- it_cdrs = ao2_iterator_init(active_cdrs_by_channel, 0);<br>+ it_cdrs = ao2_iterator_init(active_cdrs_master, 0);<br> for (; (cdr = ao2_iterator_next(&it_cdrs)); ao2_cleanup(cdr)) {<br> struct cdr_object *it_cdr;<br> struct timeval start_time = { 0, };<br>@@ -4302,7 +4306,7 @@<br> <br> STASIS_MESSAGE_TYPE_CLEANUP(cdr_sync_message_type);<br> <br>- ao2_callback(active_cdrs_by_channel, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK,<br>+ ao2_callback(active_cdrs_master, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK,<br> cdr_object_dispatch_all_cb, NULL);<br> finalize_batch_mode();<br> ast_cli_unregister_multiple(cli_commands, ARRAY_LEN(cli_commands));<br>@@ -4314,9 +4318,9 @@<br> aco_info_destroy(&cfg_info);<br> ao2_global_obj_release(module_configs);<br> <br>- ao2_container_unregister("cdrs_by_channel");<br>- ao2_cleanup(active_cdrs_by_channel);<br>- active_cdrs_by_channel = NULL;<br>+ ao2_container_unregister("cdrs_master");<br>+ ao2_cleanup(active_cdrs_master);<br>+ active_cdrs_master = NULL;<br> <br> ao2_container_unregister("cdrs_all");<br> ao2_cleanup(active_cdrs_all);<br>@@ -4345,25 +4349,28 @@<br> <br> /*!<br> * \internal<br>- * \brief Print channel object key (name).<br>+ * \brief Print master CDR container object.<br> * \since 12.0.0<br> *<br>- * \param v_obj A pointer to the object we want the key printed.<br>+ * \param v_obj A pointer to the object we want printed.<br> * \param where User data needed by prnt to determine where to put output.<br> * \param prnt Print output callback function to use.<br> *<br> * \return Nothing<br> */<br>-static void cdr_container_print_fn(void *v_obj, void *where, ao2_prnt_fn *prnt)<br>+static void cdr_master_print_fn(void *v_obj, void *where, ao2_prnt_fn *prnt)<br> {<br> struct cdr_object *cdr = v_obj;<br> struct cdr_object *it_cdr;<br>+<br> if (!cdr) {<br> return;<br> }<br> for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->next) {<br>- prnt(where, "Party A: %s; Party B: %s; Bridge %s\n", it_cdr->party_a.snapshot->name, it_cdr->party_b.snapshot ? it_cdr->party_b.snapshot->name : "<unknown>",<br>- it_cdr->bridge);<br>+ prnt(where, "Party A: %s; Party B: %s; Bridge %s\n",<br>+ it_cdr->party_a.snapshot->name,<br>+ it_cdr->party_b.snapshot ? it_cdr->party_b.snapshot->name : "<unknown>",<br>+ it_cdr->bridge);<br> }<br> }<br> <br>@@ -4450,12 +4457,12 @@<br> stasis_message_router_add(stasis_router, ast_parked_call_type(), handle_parked_call_message, NULL);<br> stasis_message_router_add(stasis_router, cdr_sync_message_type(), handle_cdr_sync_message, NULL);<br> <br>- active_cdrs_by_channel = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0,<br>- NUM_CDR_BUCKETS, cdr_object_channel_hash_fn, NULL, cdr_object_channel_cmp_fn);<br>- if (!active_cdrs_by_channel) {<br>+ active_cdrs_master = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0,<br>+ NUM_CDR_BUCKETS, cdr_master_hash_fn, NULL, cdr_master_cmp_fn);<br>+ if (!active_cdrs_master) {<br> return -1;<br> }<br>- ao2_container_register("cdrs_by_channel", active_cdrs_by_channel, cdr_container_print_fn);<br>+ ao2_container_register("cdrs_master", active_cdrs_master, cdr_master_print_fn);<br> <br> active_cdrs_all = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0,<br> NUM_CDR_BUCKETS, cdr_all_hash_fn, NULL, cdr_all_cmp_fn);<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6766">change 6766</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/6766"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I6104bb3edc3a0b7243ce502e45e8832b0cff14f7 </div>
<div style="display:none"> Gerrit-Change-Number: 6766 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>