<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/6723">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 df5d99b..ddbed5f 100644<br>--- a/main/cdr.c<br>+++ b/main/cdr.c<br>@@ -1567,11 +1567,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>@@ -1593,6 +1592,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>@@ -1715,11 +1715,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>@@ -1754,6 +1753,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>@@ -1924,7 +1924,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>@@ -1960,7 +1960,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>@@ -2000,15 +1999,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>@@ -2082,7 +2078,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>@@ -2110,12 +2106,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>@@ -2123,6 +2118,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>@@ -2132,6 +2128,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>@@ -2157,6 +2154,7 @@<br> old_snapshot);<br> }<br> <br>+ ao2_cleanup(cdr);<br> }<br> <br> struct bridge_leave_data {<br>@@ -2219,9 +2217,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>@@ -2242,6 +2238,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>@@ -2262,16 +2259,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>@@ -2376,16 +2373,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>@@ -2522,9 +2516,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>@@ -2541,6 +2533,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>@@ -2552,6 +2545,7 @@<br> } else {<br> handle_standard_bridge_enter_message(cdr, bridge, channel);<br> }<br>+ ao2_cleanup(cdr);<br> }<br> <br> /*!<br>@@ -2566,7 +2560,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>@@ -2608,7 +2602,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>@@ -2619,6 +2615,7 @@<br> <br> ao2_unlock(cdr);<br> <br>+ ao2_cleanup(cdr);<br> }<br> <br> /*!<br>@@ -3111,15 +3108,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>@@ -3133,18 +3131,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>@@ -3193,6 +3193,7 @@<br> }<br> }<br> ao2_unlock(cdr);<br>+ ao2_cleanup(cdr);<br> return total;<br> }<br> <br>@@ -3260,7 +3261,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>@@ -3268,6 +3269,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>@@ -3284,6 +3286,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>@@ -3322,9 +3325,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>@@ -3342,14 +3346,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>@@ -3363,15 +3369,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>@@ -3399,6 +3407,7 @@<br> }<br> ao2_unlock(cdr);<br> <br>+ ao2_cleanup(cdr);<br> return 0;<br> }<br> <br>@@ -3808,7 +3817,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>@@ -3853,6 +3862,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>@@ -4267,8 +4279,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>@@ -4278,9 +4288,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>@@ -4290,6 +4307,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/6723">change 6723</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/6723"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 14 </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: 6723 </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>