[Asterisk-code-review] cdr: Minor optimizations. (asterisk[13])
Jenkins2
asteriskteam at digium.com
Mon Dec 18 08:36:08 CST 2017
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/7607 )
Change subject: cdr: Minor optimizations.
......................................................................
cdr: Minor optimizations.
* bridge_candidate_process: remove SCOPED_AO2LOCK and return value.
* handle_standard_bridge_enter_message: replace recursive call with goto
statement.
ASTERISK-24297
Change-Id: Id2eaa0822fb8dc799f63422bb3aa89de9d4ee2a2
---
M main/cdr.c
1 file changed, 10 insertions(+), 7 deletions(-)
Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Jenkins2: Approved for Submit
diff --git a/main/cdr.c b/main/cdr.c
index 60532fe..7f010f0 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -2454,12 +2454,12 @@
* \param cand_cdr The \ref cdr_object that is a candidate
*
*/
-static int bridge_candidate_process(struct cdr_object *cdr, struct cdr_object *base_cand_cdr)
+static void bridge_candidate_process(struct cdr_object *cdr, struct cdr_object *base_cand_cdr)
{
struct cdr_object_snapshot *party_a;
struct cdr_object *cand_cdr;
- SCOPED_AO2LOCK(lock, base_cand_cdr);
+ ao2_lock(base_cand_cdr);
for (cand_cdr = base_cand_cdr; cand_cdr; cand_cdr = cand_cdr->next) {
/* Skip any records that are not in this bridge */
@@ -2471,7 +2471,7 @@
if (!strcasecmp(cdr->party_a.snapshot->name, cand_cdr->party_a.snapshot->name)
|| (cdr->party_b.snapshot
&& !strcasecmp(cdr->party_b.snapshot->name, cand_cdr->party_a.snapshot->name))) {
- return 0;
+ break;
}
party_a = cdr_object_pick_party_a(&cdr->party_a, &cand_cdr->party_a);
@@ -2479,7 +2479,7 @@
* Party B */
if (!strcasecmp(party_a->snapshot->name, cdr->party_a.snapshot->name)) {
bridge_candidate_add_to_cdr(cdr, &cand_cdr->party_a);
- return 0;
+ break;
}
/* We're Party B. Check if we can add ourselves immediately or if we need
@@ -2499,9 +2499,11 @@
*/
memset(&cand_cdr->end, 0, sizeof(cand_cdr->end));
}
- return 0;
+
+ break;
}
- return 0;
+
+ ao2_unlock(base_cand_cdr);
}
/*!
@@ -2584,6 +2586,7 @@
ao2_lock(cdr);
+try_again:
for (it_cdr = cdr; it_cdr; it_cdr = it_cdr->next) {
if (it_cdr->fn_table->process_party_a) {
CDR_DEBUG("%p - Updating Party A %s snapshot\n", it_cdr,
@@ -2636,7 +2639,7 @@
/* This is guaranteed to succeed: the new CDR is created in the single state
* and will be able to handle the bridge enter message
*/
- handle_standard_bridge_enter_message(cdr, bridge, channel);
+ goto try_again;
}
}
ao2_unlock(cdr);
--
To view, visit https://gerrit.asterisk.org/7607
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: Id2eaa0822fb8dc799f63422bb3aa89de9d4ee2a2
Gerrit-Change-Number: 7607
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171218/27411ff9/attachment.html>
More information about the asterisk-code-review
mailing list