<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/6725">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Corey Farrell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
Sean Bright: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cdr.c: Eliminated simple RAII_VAR usages.<br><br>Change-Id: I150505db307249a962987e7b941bdd369bb91f35<br>---<br>M main/cdr.c<br>1 file changed, 74 insertions(+), 55 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 b94bbcf..1ea2445 100644<br>--- a/main/cdr.c<br>+++ b/main/cdr.c<br>@@ -1564,11 +1564,10 @@<br> for (it_cdrs = ao2_iterator_init(bridge->channels, 0);<br> !success && (channel_id = ao2_iterator_next(&it_cdrs));<br> ao2_ref(channel_id, -1)) {<br>- RAII_VAR(struct cdr_object *, cand_cdr_master,<br>- ao2_find(active_cdrs_by_channel, channel_id, OBJ_SEARCH_KEY),<br>- ao2_cleanup);<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> if (!cand_cdr_master) {<br> continue;<br> }<br>@@ -1590,6 +1589,7 @@<br> break;<br> }<br> ao2_unlock(cand_cdr_master);<br>+ ao2_cleanup(cand_cdr_master);<br> }<br> ao2_iterator_destroy(&it_cdrs);<br> <br>@@ -1712,11 +1712,10 @@<br> for (it_cdrs = ao2_iterator_init(bridge->channels, 0);<br> !success && (channel_id = ao2_iterator_next(&it_cdrs));<br> ao2_ref(channel_id, -1)) {<br>- RAII_VAR(struct cdr_object *, cand_cdr_master,<br>- ao2_find(active_cdrs_by_channel, channel_id, OBJ_SEARCH_KEY),<br>- ao2_cleanup);<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> if (!cand_cdr_master) {<br> continue;<br> }<br>@@ -1751,6 +1750,7 @@<br> break;<br> }<br> ao2_unlock(cand_cdr_master);<br>+ ao2_cleanup(cand_cdr_master);<br> }<br> ao2_iterator_destroy(&it_cdrs);<br> <br>@@ -1921,7 +1921,7 @@<br> static void handle_dial_message(void *data, struct stasis_subscription *sub, struct stasis_message *message)<br> {<br> RAII_VAR(struct module_config *, mod_cfg, ao2_global_obj_ref(module_configs), ao2_cleanup);<br>- RAII_VAR(struct cdr_object *, cdr, NULL, ao2_cleanup);<br>+ struct cdr_object *cdr;<br> struct ast_multi_channel_blob *payload = stasis_message_data(message);<br> struct ast_channel_snapshot *caller;<br> struct ast_channel_snapshot *peer;<br>@@ -1957,7 +1957,6 @@<br> } else {<br> cdr = ao2_find(active_cdrs_by_channel, peer->uniqueid, OBJ_SEARCH_KEY);<br> }<br>-<br> if (!cdr) {<br> ast_log(AST_LOG_WARNING, "No CDR for channel %s\n", caller ? caller->name : peer->name);<br> ast_assert(0);<br>@@ -1997,15 +1996,12 @@<br> struct cdr_object *new_cdr;<br> <br> new_cdr = cdr_object_create_and_append(cdr);<br>- if (!new_cdr) {<br>- ao2_unlock(cdr);<br>- return;<br>+ if (new_cdr) {<br>+ new_cdr->fn_table->process_dial_begin(new_cdr, caller, peer);<br> }<br>- new_cdr->fn_table->process_dial_begin(new_cdr,<br>- caller,<br>- peer);<br> }<br> ao2_unlock(cdr);<br>+ ao2_cleanup(cdr);<br> }<br> <br> static int cdr_object_finalize_party_b(void *obj, void *arg, int flags)<br>@@ -2079,7 +2075,7 @@<br> */<br> static void handle_channel_cache_message(void *data, struct stasis_subscription *sub, struct stasis_message *message)<br> {<br>- RAII_VAR(struct cdr_object *, cdr, NULL, ao2_cleanup);<br>+ struct cdr_object *cdr;<br> RAII_VAR(struct module_config *, mod_cfg, ao2_global_obj_ref(module_configs), ao2_cleanup);<br> struct stasis_cache_update *update = stasis_message_data(message);<br> struct ast_channel_snapshot *old_snapshot;<br>@@ -2107,12 +2103,11 @@<br> }<br> cdr->is_root = 1;<br> ao2_link(active_cdrs_by_channel, cdr);<br>+ } else {<br>+ cdr = ao2_find(active_cdrs_by_channel, uniqueid, OBJ_SEARCH_KEY);<br> }<br> <br> /* Handle Party A */<br>- if (!cdr) {<br>- cdr = ao2_find(active_cdrs_by_channel, uniqueid, OBJ_SEARCH_KEY);<br>- }<br> if (!cdr) {<br> ast_log(AST_LOG_WARNING, "No CDR for channel %s\n", name);<br> ast_assert(0);<br>@@ -2120,6 +2115,7 @@<br> ao2_lock(cdr);<br> if (new_snapshot) {<br> int all_reject = 1;<br>+<br> for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->next) {<br> if (!it_cdr->fn_table->process_party_a) {<br> continue;<br>@@ -2129,6 +2125,7 @@<br> if (all_reject && check_new_cdr_needed(old_snapshot, new_snapshot)) {<br> /* We're not hung up and we have a new snapshot - we need a new CDR */<br> struct cdr_object *new_cdr;<br>+<br> new_cdr = cdr_object_create_and_append(cdr);<br> if (new_cdr) {<br> new_cdr->fn_table->process_party_a(new_cdr, new_snapshot);<br>@@ -2154,6 +2151,7 @@<br> old_snapshot);<br> }<br> <br>+ ao2_cleanup(cdr);<br> }<br> <br> struct bridge_leave_data {<br>@@ -2216,9 +2214,7 @@<br> struct ast_channel_snapshot *channel = update->channel;<br> RAII_VAR(struct module_config *, mod_cfg,<br> ao2_global_obj_ref(module_configs), ao2_cleanup);<br>- RAII_VAR(struct cdr_object *, cdr,<br>- ao2_find(active_cdrs_by_channel, channel->uniqueid, OBJ_SEARCH_KEY),<br>- ao2_cleanup);<br>+ struct cdr_object *cdr;<br> struct cdr_object *it_cdr;<br> struct bridge_leave_data leave_data = {<br> .bridge = bridge,<br>@@ -2239,6 +2235,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> if (!cdr) {<br> ast_log(AST_LOG_WARNING, "No CDR for channel %s\n", channel->name);<br> ast_assert(0);<br>@@ -2259,16 +2256,16 @@<br> }<br> }<br> ao2_unlock(cdr);<br>- if (!left_bridge) {<br>- return;<br>+<br>+ /* Party B */<br>+ if (left_bridge<br>+ && strcmp(bridge->subclass, "parking")) {<br>+ ao2_callback(active_cdrs_by_channel, OBJ_NODATA,<br>+ cdr_object_party_b_left_bridge_cb,<br>+ &leave_data);<br> }<br> <br>- if (strcmp(bridge->subclass, "parking")) {<br>- /* Party B */<br>- ao2_callback(active_cdrs_by_channel, OBJ_NODATA,<br>- cdr_object_party_b_left_bridge_cb,<br>- &leave_data);<br>- }<br>+ ao2_cleanup(cdr);<br> }<br> <br> /*!<br>@@ -2373,16 +2370,13 @@<br> <br> it_channels = ao2_iterator_init(bridge->channels, 0);<br> while ((channel_id = ao2_iterator_next(&it_channels))) {<br>- RAII_VAR(struct cdr_object *, cand_cdr,<br>- ao2_find(active_cdrs_by_channel, channel_id, OBJ_SEARCH_KEY),<br>- ao2_cleanup);<br>+ struct cdr_object *cand_cdr;<br> <br>- if (!cand_cdr) {<br>- ao2_ref(channel_id, -1);<br>- continue;<br>+ cand_cdr = ao2_find(active_cdrs_by_channel, channel_id, OBJ_SEARCH_KEY);<br>+ if (cand_cdr) {<br>+ bridge_candidate_process(cdr, cand_cdr);<br>+ ao2_ref(cand_cdr, -1);<br> }<br>-<br>- bridge_candidate_process(cdr, cand_cdr);<br> <br> ao2_ref(channel_id, -1);<br> }<br>@@ -2519,9 +2513,7 @@<br> struct ast_bridge_blob *update = stasis_message_data(message);<br> struct ast_bridge_snapshot *bridge = update->bridge;<br> struct ast_channel_snapshot *channel = update->channel;<br>- RAII_VAR(struct cdr_object *, cdr,<br>- ao2_find(active_cdrs_by_channel, channel->uniqueid, OBJ_SEARCH_KEY),<br>- ao2_cleanup);<br>+ struct cdr_object *cdr;<br> RAII_VAR(struct module_config *, mod_cfg,<br> ao2_global_obj_ref(module_configs), ao2_cleanup);<br> <br>@@ -2538,6 +2530,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> if (!cdr) {<br> ast_log(AST_LOG_WARNING, "No CDR for channel %s\n", channel->name);<br> ast_assert(0);<br>@@ -2549,6 +2542,7 @@<br> } else {<br> handle_standard_bridge_enter_message(cdr, bridge, channel);<br> }<br>+ ao2_cleanup(cdr);<br> }<br> <br> /*!<br>@@ -2563,7 +2557,7 @@<br> {<br> struct ast_parked_call_payload *payload = stasis_message_data(message);<br> struct ast_channel_snapshot *channel = payload->parkee;<br>- RAII_VAR(struct cdr_object *, cdr, NULL, ao2_cleanup);<br>+ struct cdr_object *cdr;<br> RAII_VAR(struct module_config *, mod_cfg,<br> ao2_global_obj_ref(module_configs), ao2_cleanup);<br> int unhandled = 1;<br>@@ -2605,7 +2599,9 @@<br> <br> if (unhandled) {<br> /* Nothing handled the messgae - we need a new one! */<br>- struct cdr_object *new_cdr = cdr_object_create_and_append(cdr);<br>+ struct cdr_object *new_cdr;<br>+<br>+ new_cdr = cdr_object_create_and_append(cdr);<br> if (new_cdr) {<br> /* As the new CDR is created in the single state, it is guaranteed<br> * to have a function for the parked call message and will handle<br>@@ -2616,6 +2612,7 @@<br> <br> ao2_unlock(cdr);<br> <br>+ ao2_cleanup(cdr);<br> }<br> <br> /*!<br>@@ -3108,15 +3105,16 @@<br> <br> int ast_cdr_getvar(const char *channel_name, const char *name, char *value, size_t length)<br> {<br>- RAII_VAR(struct cdr_object *, cdr, cdr_object_get_by_name(channel_name), ao2_cleanup);<br>+ struct cdr_object *cdr;<br> struct cdr_object *cdr_obj;<br> <br>- if (!cdr) {<br>- ast_log(AST_LOG_ERROR, "Unable to find CDR for channel %s\n", channel_name);<br>+ if (ast_strlen_zero(name)) {<br> return 1;<br> }<br> <br>- if (ast_strlen_zero(name)) {<br>+ cdr = cdr_object_get_by_name(channel_name);<br>+ if (!cdr) {<br>+ ast_log(AST_LOG_ERROR, "Unable to find CDR for channel %s\n", channel_name);<br> return 1;<br> }<br> <br>@@ -3130,18 +3128,20 @@<br> <br> ao2_unlock(cdr);<br> <br>+ ao2_cleanup(cdr);<br> return 0;<br> }<br> <br> int ast_cdr_serialize_variables(const char *channel_name, struct ast_str **buf, char delim, char sep)<br> {<br>- RAII_VAR(struct cdr_object *, cdr, cdr_object_get_by_name(channel_name), ao2_cleanup);<br>+ struct cdr_object *cdr;<br> struct cdr_object *it_cdr;<br> struct ast_var_t *variable;<br> const char *var;<br> char workspace[256];<br> int total = 0, x = 0, i;<br> <br>+ cdr = cdr_object_get_by_name(channel_name);<br> if (!cdr) {<br> RAII_VAR(struct module_config *, mod_cfg,<br> ao2_global_obj_ref(module_configs), ao2_cleanup);<br>@@ -3190,6 +3190,7 @@<br> }<br> }<br> ao2_unlock(cdr);<br>+ ao2_cleanup(cdr);<br> return total;<br> }<br> <br>@@ -3257,7 +3258,7 @@<br> <br> void ast_cdr_setuserfield(const char *channel_name, const char *userfield)<br> {<br>- RAII_VAR(struct cdr_object *, cdr, cdr_object_get_by_name(channel_name), ao2_cleanup);<br>+ struct cdr_object *cdr;<br> struct party_b_userfield_update party_b_info = {<br> .channel_name = channel_name,<br> .userfield = userfield,<br>@@ -3265,6 +3266,7 @@<br> struct cdr_object *it_cdr;<br> <br> /* Handle Party A */<br>+ cdr = cdr_object_get_by_name(channel_name);<br> if (cdr) {<br> ao2_lock(cdr);<br> for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->next) {<br>@@ -3281,6 +3283,7 @@<br> cdr_object_update_party_b_userfield_cb,<br> &party_b_info);<br> <br>+ ao2_cleanup(cdr);<br> }<br> <br> static void post_cdr(struct ast_cdr *cdr)<br>@@ -3319,9 +3322,10 @@<br> <br> int ast_cdr_set_property(const char *channel_name, enum ast_cdr_options option)<br> {<br>- RAII_VAR(struct cdr_object *, cdr, cdr_object_get_by_name(channel_name), ao2_cleanup);<br>+ struct cdr_object *cdr;<br> struct cdr_object *it_cdr;<br> <br>+ cdr = cdr_object_get_by_name(channel_name);<br> if (!cdr) {<br> return -1;<br> }<br>@@ -3339,14 +3343,16 @@<br> }<br> ao2_unlock(cdr);<br> <br>+ ao2_cleanup(cdr);<br> return 0;<br> }<br> <br> int ast_cdr_clear_property(const char *channel_name, enum ast_cdr_options option)<br> {<br>- RAII_VAR(struct cdr_object *, cdr, cdr_object_get_by_name(channel_name), ao2_cleanup);<br>+ struct cdr_object *cdr;<br> struct cdr_object *it_cdr;<br> <br>+ cdr = cdr_object_get_by_name(channel_name);<br> if (!cdr) {<br> return -1;<br> }<br>@@ -3360,15 +3366,17 @@<br> }<br> ao2_unlock(cdr);<br> <br>+ ao2_cleanup(cdr);<br> return 0;<br> }<br> <br> int ast_cdr_reset(const char *channel_name, int keep_variables)<br> {<br>- RAII_VAR(struct cdr_object *, cdr, cdr_object_get_by_name(channel_name), ao2_cleanup);<br>+ struct cdr_object *cdr;<br> struct ast_var_t *vardata;<br> struct cdr_object *it_cdr;<br> <br>+ cdr = cdr_object_get_by_name(channel_name);<br> if (!cdr) {<br> return -1;<br> }<br>@@ -3396,6 +3404,7 @@<br> }<br> ao2_unlock(cdr);<br> <br>+ ao2_cleanup(cdr);<br> return 0;<br> }<br> <br>@@ -3805,7 +3814,7 @@<br> char answer_time_buffer[64];<br> char end_time_buffer[64];<br> const char *channel_name = a->argv[3];<br>- RAII_VAR(struct cdr_object *, cdr, NULL, ao2_cleanup);<br>+ struct cdr_object *cdr;<br> <br> #define TITLE_STRING "%-10.10s %-20.20s %-25.25s %-15.15s %-15.15s %-8.8s %-8.8s %-8.8s %-8.8s %-8.8s\n"<br> #define FORMAT_STRING "%-10.10s %-20.20s %-25.25s %-15.15s %-15.15s %-8.8s %-8.8s %-8.8s %-8.8ld %-8.8ld\n"<br>@@ -3850,6 +3859,9 @@<br> (long)ast_tvdiff_ms(end, it_cdr->start) / 1000);<br> }<br> ao2_unlock(cdr);<br>+<br>+ ao2_cleanup(cdr);<br>+<br> #undef FORMAT_STRING<br> #undef TITLE_STRING<br> }<br>@@ -4264,8 +4276,6 @@<br> void ast_cdr_engine_term(void)<br> {<br> RAII_VAR(struct module_config *, mod_cfg, ao2_global_obj_ref(module_configs), ao2_cleanup);<br>- RAII_VAR(void *, payload, NULL, ao2_cleanup);<br>- RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);<br> <br> /* Since this is called explicitly during process shutdown, we might not have ever<br> * been initialized. If so, the config object will be NULL.<br>@@ -4275,9 +4285,16 @@<br> }<br> <br> if (cdr_sync_message_type()) {<br>+ void *payload;<br>+ struct stasis_message *message;<br>+<br>+ if (!stasis_router) {<br>+ return;<br>+ }<br>+<br> /* Make sure we have the needed items */<br> payload = ao2_alloc(sizeof(*payload), NULL);<br>- if (!stasis_router || !payload) {<br>+ if (!payload) {<br> return;<br> }<br> <br>@@ -4287,6 +4304,8 @@<br> if (message) {<br> stasis_message_router_publish_sync(stasis_router, message);<br> }<br>+ ao2_cleanup(message);<br>+ ao2_cleanup(payload);<br> }<br> <br> if (ast_test_flag(&mod_cfg->general->settings, CDR_BATCHMODE)) {<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6725">change 6725</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/6725"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I150505db307249a962987e7b941bdd369bb91f35 </div>
<div style="display:none"> Gerrit-Change-Number: 6725 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.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>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>