Commit ff4a0f59 authored by Rohan Garg's avatar Rohan Garg Committed by Youness Alaoui

Fix a minor bug in the dribble mode test

If for some reason the opening of the socket is delayed, or simply takes
too much time, the test will fail. This patch ensures that the test will
only proceed once the socket is open.
parent 78a1099c
......@@ -60,11 +60,17 @@
#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;
......@@ -214,6 +220,10 @@ static gpointer stun_thread_func (const gpointer user_data)
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,
......@@ -654,6 +664,11 @@ int main(void)
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),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment