[Asterisk-code-review] res pjsip registrar: lock transport monitor when setting 're... (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Thu Feb 7 11:04:37 CST 2019


Richard Mudgett has posted comments on this change. ( https://gerrit.asterisk.org/10968 )

Change subject: res_pjsip_registrar: lock transport monitor when setting 'removing' flag
......................................................................


Patch Set 1: Code-Review-1

(3 comments)

https://gerrit.asterisk.org/#/c/10968/1/res/res_pjsip_registrar.c
File res/res_pjsip_registrar.c:

https://gerrit.asterisk.org/#/c/10968/1/res/res_pjsip_registrar.c@343
PS1, Line 343: 	if (!lock) {
             : 		ao2_ref(monitor, -1);
             : 		return 0;
             : 	}
We might want to clear the monitor->removing flag on failure here to potentially give removing another shot.

if !lock then
  lock monitor
  removing = 0
  unlock monitor
  unref monitor
  return 0


https://gerrit.asterisk.org/#/c/10968/1/res/res_pjsip_registrar.c@408
PS1, Line 408: 	if (ast_sip_push_task(NULL, register_contact_transport_remove_cb, monitor)) {
             : 		ao2_ref(monitor, -1);
Maybe should hold the monitor lock until after pushing the task in case of failure.  Then you can clear the monitor->removing flag.

lock monitor
if removing
   unlock monitor
   return

removing = 1

ref monitor
if push_task
  removing = 0
  unref monitor
unlock monitor


https://gerrit.asterisk.org/#/c/10968/1/res/res_pjsip_registrar.c@722
PS1, Line 722: 					+ strlen(contact_name), NULL, AO2_ALLOC_OPT_LOCK_RWLOCK);
You are not using the rwlock features.  You just need a mutex:
AO2_ALLOC_OPT_LOCK_MUTEX



-- 
To view, visit https://gerrit.asterisk.org/10968
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: comment
Gerrit-Change-Id: Iaa8e36e5311789549b76d8de42dfcea96013b2ed
Gerrit-Change-Number: 10968
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Friendly Automation (1000185)
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Comment-Date: Thu, 07 Feb 2019 17:04:37 +0000
Gerrit-HasComments: Yes
Gerrit-HasLabels: Yes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190207/f4f1027b/attachment.html>


More information about the asterisk-code-review mailing list