diff options
author | Jakub Adam <jakub.adam@ktknet.cz> | 2016-06-01 08:52:41 +0000 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2016-06-01 11:14:08 -0400 |
commit | 1a23476513d487bb09afbc7fb4853169399312d7 (patch) | |
tree | 22eee8e651f3e47e5440711bdc226d5bcd71642c /tests | |
parent | b559384734deb9ec934f5ff69814f3d90c6a36c1 (diff) | |
download | libnice-1a23476513d487bb09afbc7fb4853169399312d7.tar.gz |
test-icetcp: don't be sensitive to the signal order
"new-selected-pair" may be emitted after "component-state-changed"
to READY, by which time the main loop might have gotten quit in
cb_component_state_changed(). Consequently, cb_new_selected_pair() could
miss to register the selected pair, ultimately leading to an assertion
failure in main().
We should wait for both selected pair and state change events to occur
before stopping the main loop.
Differential Revision: https://phabricator.freedesktop.org/D1044
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-icetcp.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/test-icetcp.c b/tests/test-icetcp.c index 6812469..5b2b4b2 100644 --- a/tests/test-icetcp.c +++ b/tests/test-icetcp.c @@ -125,6 +125,14 @@ static void cb_candidate_gathering_done(NiceAgent *agent, guint stream_id, gpoin (void)agent; } +static void check_loop_quit_condition (void) +{ + if (global_ready_reached && + global_lagent_cands >= 2 && global_ragent_cands >= 2) { + g_main_loop_quit (global_mainloop); + } +} + static void cb_component_state_changed (NiceAgent *agent, guint stream_id, guint component_id, guint state, gpointer data) { gboolean ready_to_connected = FALSE; @@ -158,10 +166,10 @@ static void cb_component_state_changed (NiceAgent *agent, guint stream_id, guint global_ready_reached == FALSE) { g_debug ("Components ready/failed achieved. Stopping mailoop"); global_ready_reached = TRUE; - g_main_loop_quit (global_mainloop); - return; } + check_loop_quit_condition (); + #if 0 /* signal status via a global variable */ if (global_components_failed == global_components_failed_exit) { @@ -184,6 +192,8 @@ static void cb_new_selected_pair(NiceAgent *agent, guint stream_id, guint compon else if (GPOINTER_TO_UINT (data) == 2) ++global_ragent_cands; + check_loop_quit_condition (); + /* XXX: dear compiler, these are for you: */ (void)agent; (void)stream_id; (void)component_id; (void)lfoundation; (void)rfoundation; } |