[Asterisk-code-review] res xmpp: Prevent deadlock on module unload (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Thu Mar 30 10:47:25 CDT 2017


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

Change subject: res_xmpp: Prevent deadlock on module unload
......................................................................


Patch Set 1:

> > > > It would be better to fix the global obj to release the obj
 > ref
 > > > > outside of the global rwlock in astobj2.c.  There are a
 > couple
 > > > > other global obj functions that may do the same thing.
 > > >
 > > > The only thing that ao2_global_obj_release() does is grab the
 > > lock,
 > > > deref the object, and unlock. Short of just removing the lock,
 > I
 > > > don't know how I would "fix" it.
 > >
 > > I was thinking you would simply need to defer unreffing the
 > object
 > > until after the lock was released to fix this deadlock problem.
 > 
 > OK, so I grab the write lock, copy the holder->obj pointer, NULL
 > out the holder->obj pointer, unlock and then deref the saved
 > pointer.
 > 
 > What happens when the destructors call ao2_global_obj_ref()?

Nothing happens because ao2_global_obj_release() has replaced the object
in the global object with a NULL.  In fact ao2_global_obj_release() is
a specialized version of ao2_global_obj_replace_unref() where the new
obj is NULL.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Idf40ae136b5070dba22cb576ea8414fbc9939385
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
Gerrit-HasComments: No



More information about the asterisk-code-review mailing list