>>> You have to obtain the root (via su_root_obtain()) that is used by nta
>>> in order to access the nta objects in safe manner. (The original
>>> thread used to create the root object must first release it with
>>> su_root_release()).
>>
>> Like locking/unlocking a mutex, understood.
>>
>> I guess this also applies to nta_outgoing_tcreate() and friends. Even
>> if sending outgoing transactions of different call legs in different
>> threads, getting/releasing the root of the NTA is needed to avoid
>> problems in the internal lists of the NTA agent. Right?
>
> That is correct. The additional complication is that some thread must
> sometimes call su_root_run() or su_root_step() to keep timers and
> retransmissions running.
>

I took another way of solving this problem.

* Main thread is the one owning the NTA, running su_root_run(), so it
is the only one which can call nta_incoming_treply(),
nta_outgoing_tcreate(), nta_leg_destroy(), nta_incoming_destroy() and
such in a safely manner (the root is not obtained/released by any
other thread).

* When a new sip message is received in a given call, the
nta_incoming_t is passed to different 'worker' threads (same worker
always for same call leg), using su_msg_r. If any of the worker
threads needs to reply or create an outgoing transaction in the call
leg, it will just send a su_msg_r containing the tag list as a (tagi_t
*) and remaining arguments.

* Same for leg removal. When my internal timeouts fire, I request from
a given worker thread that the leg should be removed, also notifying
the Manager thread with a su_msg_r.

With this approach, and with quite a lot of caution, different threads
can process different input transactions in a thread-safe manner, as
the worker threads don't really need to do any job with the NTA agent.

BTW, congratulations for the job done with the (tagi_t *) list and
everything related to the tags in functions with variable-length
argument lists. It's an incredible work.

Cheers,
-Aleksander

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel

Reply via email to