Hi all,

I'm facing this problem in a multithreaded application, with a thread
running the sofia sip event callback (thread A), and another thread
(thread B) managing the deallocation of the nua handles.

The problem is that when a nua handle is destroyed by thread B, thread
A may still be processing a message associated to the nua handle and
the corresponding nua handle magic which is being destroyed by thread
B.

Currently I'm simply skipping the destruction of the nua handle magic,
which results in a leak. If I destroy the nua handle magic in thread B
this may result in an occasional crash when thread A tries to access
the nua handle magic which is being destroyed.

A possible solution would be to delay the destruction of the nua
handle magic after the corresponding nua handle has been destroyed,
this way I would be pretty sure that the thread A is not anymore
processing messages associated to the destroyed nua handle, but as you
may guess this may not work in case of slowdowns.

So the problem seems that when I'm processing nua handle+magic in
thread A I'm not sure if nua handle+magic still exist.

I wonder if it would be possible to make nua send a final message to
the nua thread *after* nua_handle has been destroyed with
nua_handle_destroy() or a corresponding command. If this would be
possible, then I could safely destroy the handle in thread B, and let
thread A destroy the nua handle magic in thread A when this final
message is received.

Can you say if this would be feasible, or suggest a valid solution to
the problem?

TAI, regards.

------------------------------------------------------------------------------
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel

Reply via email to