[Asterisk-code-review] astobj2: Add ao2 weakproxy find function. (asterisk[master])

Richard Mudgett asteriskteam at digium.com
Tue Oct 10 13:47:16 CDT 2017


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

Change subject: astobj2: Add ao2_weakproxy_find function.
......................................................................


Patch Set 1: Code-Review-1

(5 comments)

https://gerrit.asterisk.org/#/c/6710/1/main/astobj2_container.c
File main/astobj2_container.c:

https://gerrit.asterisk.org/#/c/6710/1/main/astobj2_container.c@458
PS1, Line 458: 	if (!(flags & OBJ_NOLOCK)) {
             : 		ao2_lock(c);
             : 	}
This should be done like in internal_ao2_traverse().  The weak object container doesn't have any restrictions on what kind of lock it has if any.


https://gerrit.asterisk.org/#/c/6710/1/main/astobj2_container.c@465
PS1, Line 465: 		/* Never lock proxy while instances is already locked. */
Comment:
/* 
 * We cannot get the real object while the proxy container
 * is locked.  We would deadlock.
 */


Seems like this should be fixed so that the weak proxy subscription callbacks are not called while the proxy is locked.


https://gerrit.asterisk.org/#/c/6710/1/main/astobj2_container.c@470
PS1, Line 470: 		if (obj) {
             : 			/* We have an existing object and it's not being destroyed. */
             : 			ao2_ref(proxy, -1);
             : 
             : 			return obj;
             : 		}
This is always returning with the container locked.


https://gerrit.asterisk.org/#/c/6710/1/main/astobj2_container.c@478
PS1, Line 478: 		ao2_unlink_flags(c, proxy, OBJ_NOLOCK);
I think we would want to use __adjust_lock() to set the container lock so it doesn't have to be readjusted by the unlink and subsequent find.


https://gerrit.asterisk.org/#/c/6710/1/main/astobj2_container.c@481
PS1, Line 481: 		if (tries >= 3) {
             : 			/* Unlikely but not impossible.  Bail to avoid infinate loop. */
             : 			*ret = -1;
             : 			break;
             : 		}
How could you have an infinite loop?  Every dying proxy is explicitly removed from the container above and thus prevents finding it again.

Also a container could have more than three duplicate objects in it.



-- 
To view, visit https://gerrit.asterisk.org/6710
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I9da822049747275f5961b5c0a7f14e87157d65d8
Gerrit-Change-Number: 6710
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: 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>
Gerrit-Comment-Date: Tue, 10 Oct 2017 18:47:16 +0000
Gerrit-HasComments: Yes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171010/cd0172d6/attachment.html>


More information about the asterisk-code-review mailing list