[pjsip] Multiple concurent UDP transports
bennylp at teluu.com
Wed Dec 9 03:19:43 EST 2009
On Wed, Dec 9, 2009 at 7:57 AM, Liu Jahow <jahowliu at gmail.com> wrote:
> Hi Benny,
> Thanks for your advice. But for the pjsua_destroy, I have already bound the
> transport id for each account. The pjsua_destroy still does not close my
> first one udp port. Further more, if I try to re-create the transport with
> the same port after pjsua_destroy, it will fail because the port is in use.
> The version of pjsip I use is 1.4.0.
You're correct actually, sorry!
The UDP transport assumes that it is a permanent transport (compared
to incoming/outgoing TCP connections, which are ephemeral and will be
cleaned up if nothing is referencing it), so it will have the
reference counter initialized to 1 upon creation. So even if nothing
is referencing it, it will still have reference counter value 1. So
indeed, you need to shut it down manually to clean it up.
Or alternatively, you could call pjsip_transport_dec_ref() once as
soon as an account has been bound to the transport, to remove the +1
reference counter value. This way when nothing is referencing the
transport, it will be closed automatically. But you will need to be
careful to not accidently cause the reference counter to go to zero
(for example, if you delete and re-add the account).
More information about the pjsip