[Asterisk-code-review] res pjsip/pjsip distributor.c: Pull some assignments out of ... (asterisk[master])
Jenkins2
asteriskteam at digium.com
Thu May 3 07:14:48 CDT 2018
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/8892 )
Change subject: res_pjsip/pjsip_distributor.c: Pull some assignments out of if tests.
......................................................................
res_pjsip/pjsip_distributor.c: Pull some assignments out of if tests.
Change-Id: I3d30d638b53a4bbe9bf9aad853c649d583894112
---
M res/res_pjsip/pjsip_distributor.c
1 file changed, 16 insertions(+), 10 deletions(-)
Approvals:
Corey Farrell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved
Jenkins2: Approved for Submit
diff --git a/res/res_pjsip/pjsip_distributor.c b/res/res_pjsip/pjsip_distributor.c
index 33d4bce..68a0cbc 100644
--- a/res/res_pjsip/pjsip_distributor.c
+++ b/res/res_pjsip/pjsip_distributor.c
@@ -690,7 +690,8 @@
* the find without OBJ_UNLINK to prevent the unnecessary write lock, then unlink
* if needed.
*/
- if ((unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY))) {
+ unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY);
+ if (unid) {
ao2_unlink(unidentified_requests, unid);
ao2_ref(unid, -1);
}
@@ -699,14 +700,14 @@
endpoint = ast_sip_identify_endpoint(rdata);
if (endpoint) {
- if ((unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY))) {
+ unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY);
+ if (unid) {
ao2_unlink(unidentified_requests, unid);
ao2_ref(unid, -1);
}
}
if (!endpoint) {
-
/* always use an artificial endpoint - per discussion no reason
to have "alwaysauthreject" as an option. It is felt using it
was a bug fix and it is not needed since we are not worried about
@@ -715,9 +716,10 @@
endpoint = ast_sip_get_artificial_endpoint();
}
+ /* endpoint ref held by mod_data[] */
rdata->endpt_info.mod_data[endpoint_mod.id] = endpoint;
- if ((endpoint == artificial_endpoint) && !is_ack) {
+ if (endpoint == artificial_endpoint && !is_ack) {
char name[AST_UUID_STR_LEN] = "";
pjsip_uri *from = rdata->msg_info.from->uri;
@@ -726,17 +728,20 @@
ast_copy_pj_str(name, &sip_from->user, sizeof(name));
}
- if ((unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY))) {
+ unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY);
+ if (unid) {
check_endpoint(rdata, unid, name);
ao2_ref(unid, -1);
} else if (using_auth_username) {
ao2_wrlock(unidentified_requests);
- /* The check again with the write lock held allows us to eliminate the DUPS_REPLACE and sort_fn */
- if ((unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY | OBJ_NOLOCK))) {
+ /* Checking again with the write lock held allows us to eliminate the DUPS_REPLACE and sort_fn */
+ unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name,
+ OBJ_SEARCH_KEY | OBJ_NOLOCK);
+ if (unid) {
check_endpoint(rdata, unid, name);
} else {
- unid = ao2_alloc_options(sizeof(*unid) + strlen(rdata->pkt_info.src_name) + 1, NULL,
- AO2_ALLOC_OPT_LOCK_RWLOCK);
+ unid = ao2_alloc_options(sizeof(*unid) + strlen(rdata->pkt_info.src_name) + 1,
+ NULL, AO2_ALLOC_OPT_LOCK_RWLOCK);
if (!unid) {
ao2_unlock(unidentified_requests);
return PJ_TRUE;
@@ -860,7 +865,8 @@
return PJ_TRUE;
case AST_SIP_AUTHENTICATION_SUCCESS:
/* See note in endpoint_lookup about not holding an unnecessary write lock */
- if ((unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY))) {
+ unid = ao2_find(unidentified_requests, rdata->pkt_info.src_name, OBJ_SEARCH_KEY);
+ if (unid) {
ao2_unlink(unidentified_requests, unid);
ao2_ref(unid, -1);
}
--
To view, visit https://gerrit.asterisk.org/8892
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3d30d638b53a4bbe9bf9aad853c649d583894112
Gerrit-Change-Number: 8892
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180503/f1157588/attachment.html>
More information about the asterisk-code-review
mailing list