#if !GLIB_CHECK_VERSION(2,31,8)
static GMutex *stun_mutex_ptr = NULL;
static GCond *stun_signal_ptr = NULL;
+ static GMutex *stun_thread_mutex_ptr = NULL;
+ static GCond *stun_thread_signal_ptr = NULL
#else
static GMutex stun_mutex;
static GMutex *stun_mutex_ptr = &stun_mutex;
static GCond stun_signal;
static GCond *stun_signal_ptr = &stun_signal;
+ static GMutex stun_thread_mutex;
+ static GMutex *stun_thread_mutex_ptr = &stun_thread_mutex;
+ static GCond stun_thread_signal;
+ static GCond *stun_thread_signal_ptr = &stun_thread_signal;
#endif
static GMainLoop *global_mainloop;
g_assert_not_reached ();
}
+ g_mutex_lock (stun_thread_mutex_ptr);
+ g_cond_signal (stun_thread_signal_ptr);
+ g_mutex_unlock (stun_thread_mutex_ptr);
+
stun_agent_init (&oldagent, known_attributes,
STUN_COMPATIBILITY_RFC3489, 0);
stun_agent_init (&newagent, known_attributes,
stun_thread_func, NULL);
#endif
+ // Once the the thread is forked, we want to listen for a signal
+ // that the socket was opened successfully
+ g_mutex_lock (stun_thread_mutex_ptr);
+ g_cond_wait (stun_thread_signal_ptr, stun_thread_mutex_ptr);
+
lagent = nice_agent_new (g_main_loop_get_context (global_mainloop),
NICE_COMPATIBILITY_RFC5245);
ragent = nice_agent_new (g_main_loop_get_context (global_mainloop),