[Asterisk-code-review] cdr: Minor optimizations. (asterisk[master])
Corey Farrell
asteriskteam at digium.com
Fri Dec 15 10:30:37 CST 2017
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7609
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(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/09/7609/1
diff --git a/main/cdr.c b/main/cdr.c
index 3681cdc..0e03668 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -2457,12 +2457,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 */
@@ -2474,7 +2474,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);
@@ -2482,7 +2482,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
@@ -2502,9 +2502,11 @@
*/
memset(&cand_cdr->end, 0, sizeof(cand_cdr->end));
}
- return 0;
+
+ break;
}
- return 0;
+
+ ao2_unlock(base_cand_cdr);
}
/*!
@@ -2587,6 +2589,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,
@@ -2639,7 +2642,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/7609
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id2eaa0822fb8dc799f63422bb3aa89de9d4ee2a2
Gerrit-Change-Number: 7609
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171215/dfbcc96b/attachment.html>
More information about the asterisk-code-review
mailing list