Skip to content

Commit

Permalink
test-icetcp: don't be sensitive to the signal order
Browse files Browse the repository at this point in the history
"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
  • Loading branch information
xhaakon authored and ocrete committed Jun 1, 2016
1 parent b559384 commit 1a23476
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/test-icetcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down

0 comments on commit 1a23476

Please sign in to comment.