[libnice] multithread g_main_loop_quit ad remove agent

Emanuele Bizzarri emabiz76 at gmail.com
Sun Jul 6 23:40:56 PDT 2014


Hi,
I'm using libnice in order to forward rtp data among users into a star
topology network.
When one user joins, he starts to send and receive data to and from
other users.
The server forwards packets among users.
When he quit I have to remove and destroy the user reference.
But how can I be sure that the nice_agent_attach_recv callback will not
longer triggered?
Sometimes my application crashes inside the callback after I've
destroyed the user.

I'm  using a dedicated thread (T1) to manage g_main_loop_run (it is a
blocking function).
Then user is destroyed by another thread (T2).
I have tried to pause the loop using g_main_loop_quit (from T2) and wait
T1 exiting from g_main_loop_run but without success.
Probably there are pending sources/events already dispatched and when I
rerun the loop they will be triggered.
I've tried to call nice_agent_attach_recv with null callback before
destroy the user, but the problem still remains.

Can you help me please?

Which is the correct way to add and remove an agent from a loop that
manage multiple agents?

Thank you in advance,

Emanuele




More information about the nice mailing list