diff options
author | George Kiagiadakis <gkiagia@tolabaki.gr> | 2016-07-04 19:19:29 +0300 |
---|---|---|
committer | George Kiagiadakis <gkiagia@tolabaki.gr> | 2016-07-04 19:19:29 +0300 |
commit | 35194060b1f2692ab5316d0d2bc0fbe26d33e81a (patch) | |
tree | d3ff56913db2967fa8f08b78e7f90f5bc70bb614 | |
parent | 0a3f87a744031943239b8925973114147ff95aae (diff) |
wocky-connector-test: allow test server to dispatch any pending events before teardown
This is to fix an assertion failure that happens in the
"/connector+ssl/econnreset/client-open" test. In this test, the server closes
the connection and the client catches up immediately and closes too.
When the client closes, it forcibly terminates the server, but in most
cases the server's socket close operation doesn't have a chance to finish
before server teardown is called, so the teardown function hits cancel
on the GCancellable that is linked with the operation and finally
the operation ends up repording an "Operation cancelled" error.
By running the GMainLoop once before calling teardown, we ensure
that the socket close operation has a chance to finish gracefully.
-rw-r--r-- | tests/wocky-connector-test.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/wocky-connector-test.c b/tests/wocky-connector-test.c index e2622b4..a1b2b12 100644 --- a/tests/wocky-connector-test.c +++ b/tests/wocky-connector-test.c @@ -3366,6 +3366,13 @@ test_server_teardown_cb (GObject *source, g_main_loop_quit (loop); } +static gboolean +test_server_idle_quit_loop_cb (GMainLoop *loop) +{ + g_main_loop_quit (loop); + return G_SOURCE_REMOVE; +} + static void test_server_teardown (test_t *test, ServerParameters *srv) @@ -3385,6 +3392,11 @@ test_server_teardown (test_t *test, test_connector_server_get_used_mech (srv->server)); } + /* let the server dispatch any pending events before + * forcing it to tear down */ + g_idle_add ((GSourceFunc) test_server_idle_quit_loop_cb, loop); + g_main_loop_run (loop); + /* Run until server is down */ test_connector_server_teardown (srv->server, test_server_teardown_cb, loop); |