[asterisk-dev] session channel locks

Dan Cropp dan at amtelco.com
Wed Dec 9 09:27:33 CST 2020


We are working on a patch for the REFER support and have a question on whether a lock is needed or not.

In chan_pjsip.c function xfer_client_on_evsub_state, code is processing the REFER-NOTIFY subscription.

It gets an ast_sip_session reference, then it acquires a ast_channel reference.
Should we make the code bump the lock count for the session's channel while we use it?  Unlocking when done using it?

Is it safe to assume the channel will not be deleted while this routine is running?
Obviously, the safest approach is to increment/decrement the reference count while using, but is that the necessary/preferred approach?


chan = ao2_bump(session->channel);
<<use chan>>
ao2_cleanup(chan);


Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20201209/ce98047d/attachment.html>


More information about the asterisk-dev mailing list