Commit 8177bbcf authored by Simon McVittie's avatar Simon McVittie

tests: Detach most connections from main loop before closing

We don't need to do this for connections that were never set up
with the main loop.
Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall's avatarPhilip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
parent 620406f7
......@@ -1624,6 +1624,7 @@ teardown (Fixture *f,
{
dbus_connection_remove_filter (f->libdbus_observer,
observe_shouting_cb, f);
test_connection_shutdown (f->ctx, f->libdbus_observer);
dbus_connection_close (f->libdbus_observer);
}
......
......@@ -275,6 +275,7 @@ test_corrupt (Fixture *f,
* fd, whereas DBusLoop + DBusSocketSetEpoll doesn't. On Unix
* we could use dup() but that isn't portable to Windows :-(
*/
test_connection_shutdown (f->ctx, f->server_conn);
dbus_connection_close (f->server_conn);
dbus_connection_unref (f->server_conn);
f->server_conn = NULL;
......@@ -362,6 +363,7 @@ test_byte_order (Fixture *f,
dbus_message_unref (message);
/* Free the DBusConnection before the GSocket, as above. */
test_connection_shutdown (f->ctx, f->server_conn);
dbus_connection_close (f->server_conn);
dbus_connection_unref (f->server_conn);
f->server_conn = NULL;
......
......@@ -372,6 +372,7 @@ teardown (Fixture *f,
if (f->sender != NULL)
{
test_connection_shutdown (f->ctx, f->sender);
dbus_connection_close (f->sender);
dbus_connection_unref (f->sender);
f->sender = NULL;
......@@ -382,6 +383,7 @@ teardown (Fixture *f,
dbus_connection_remove_filter (f->receiver,
signal_filter, f);
test_connection_shutdown (f->ctx, f->receiver);
dbus_connection_close (f->receiver);
dbus_connection_unref (f->receiver);
f->receiver = NULL;
......@@ -392,6 +394,7 @@ teardown (Fixture *f,
dbus_connection_remove_filter (f->politelistener,
signal_filter, f);
test_connection_shutdown (f->ctx, f->politelistener);
dbus_connection_close (f->politelistener);
dbus_connection_unref (f->politelistener);
f->politelistener = NULL;
......@@ -402,6 +405,7 @@ teardown (Fixture *f,
dbus_connection_remove_filter (f->eavesdropper,
signal_filter, f);
test_connection_shutdown (f->ctx, f->eavesdropper);
dbus_connection_close (f->eavesdropper);
dbus_connection_unref (f->eavesdropper);
f->eavesdropper = NULL;
......
......@@ -364,6 +364,7 @@ test_no_reply (Fixture *f,
test_main_context_iterate (f->ctx, TRUE);
dbus_connection_remove_filter (f->right_conn, echo_filter, f);
test_connection_shutdown (f->ctx, f->right_conn);
dbus_connection_close (f->right_conn);
dbus_clear_connection (&f->right_conn);
}
......@@ -696,6 +697,7 @@ test_max_connections (Fixture *f,
dbus_connection_close (failing_conn);
dbus_clear_connection (&failing_conn);
test_connection_shutdown (f->ctx, third_conn);
dbus_connection_close (third_conn);
dbus_clear_connection (&third_conn);
dbus_error_free (&error);
......@@ -1928,7 +1930,10 @@ teardown (Fixture *f,
g_clear_error (&f->ge);
if (f->left_conn != NULL)
dbus_connection_close (f->left_conn);
{
test_connection_shutdown (f->ctx, f->left_conn);
dbus_connection_close (f->left_conn);
}
if (f->right_conn != NULL)
{
......@@ -1951,6 +1956,7 @@ teardown (Fixture *f,
g_queue_clear (&f->held_messages);
test_connection_shutdown (f->ctx, f->right_conn);
dbus_connection_close (f->right_conn);
}
......
......@@ -831,6 +831,7 @@ teardown (Fixture *f,
{
if (f->left_client_conn != NULL)
{
test_connection_shutdown (f->ctx, f->left_client_conn);
dbus_connection_close (f->left_client_conn);
dbus_connection_unref (f->left_client_conn);
f->left_client_conn = NULL;
......@@ -838,6 +839,7 @@ teardown (Fixture *f,
if (f->right_client_conn != NULL)
{
test_connection_shutdown (f->ctx, f->right_client_conn);
dbus_connection_close (f->right_client_conn);
dbus_connection_unref (f->right_client_conn);
f->right_client_conn = NULL;
......@@ -845,6 +847,7 @@ teardown (Fixture *f,
if (f->left_server_conn != NULL)
{
test_connection_shutdown (f->ctx, f->left_server_conn);
dbus_connection_close (f->left_server_conn);
dbus_connection_unref (f->left_server_conn);
f->left_server_conn = NULL;
......@@ -852,6 +855,7 @@ teardown (Fixture *f,
if (f->right_server_conn != NULL)
{
test_connection_shutdown (f->ctx, f->right_server_conn);
dbus_connection_close (f->right_server_conn);
dbus_connection_unref (f->right_server_conn);
f->right_server_conn = NULL;
......
......@@ -341,6 +341,7 @@ test_connection (Fixture *f,
/* Destroy the connection. This should be the last-unref. */
g_assert (!f->last_unref);
test_connection_shutdown (f->loop, f->connection);
dbus_connection_close (f->connection);
dbus_connection_unref (f->connection);
f->connection = NULL;
......@@ -593,12 +594,14 @@ teardown (Fixture *f,
{
if (f->server_connection != NULL)
{
test_connection_shutdown (f->loop, f->server_connection);
dbus_connection_close (f->server_connection);
dbus_connection_unref (f->server_connection);
}
if (f->connection != NULL)
{
test_connection_shutdown (f->loop, f->connection);
dbus_connection_close (f->connection);
dbus_connection_unref (f->connection);
}
......
......@@ -420,10 +420,16 @@ teardown (Fixture *f,
gconstpointer addr G_GNUC_UNUSED)
{
if (f->client_conn != NULL)
dbus_connection_close (f->client_conn);
{
test_connection_shutdown (f->ctx, f->client_conn);
dbus_connection_close (f->client_conn);
}
if (f->server_conn != NULL)
dbus_connection_close (f->server_conn);
{
test_connection_shutdown (f->ctx, f->server_conn);
dbus_connection_close (f->server_conn);
}
dbus_clear_connection (&f->client_conn);
dbus_clear_connection (&f->server_conn);
......
......@@ -1890,6 +1890,7 @@ teardown (Fixture *f,
if (f->monitor != NULL)
{
dbus_connection_remove_filter (f->monitor, monitor_filter, f);
test_connection_shutdown (f->ctx, f->monitor);
dbus_connection_close (f->monitor);
dbus_connection_unref (f->monitor);
f->monitor = NULL;
......@@ -1897,6 +1898,7 @@ teardown (Fixture *f,
if (f->sender != NULL)
{
test_connection_shutdown (f->ctx, f->sender);
dbus_connection_close (f->sender);
dbus_connection_unref (f->sender);
f->sender = NULL;
......@@ -1908,6 +1910,8 @@ teardown (Fixture *f,
if (f->recipient_enqueue_filter_added)
dbus_connection_remove_filter (f->recipient, recipient_enqueue_filter,
f);
test_connection_shutdown (f->ctx, f->recipient);
dbus_connection_close (f->recipient);
dbus_connection_unref (f->recipient);
f->recipient = NULL;
......@@ -1916,6 +1920,7 @@ teardown (Fixture *f,
if (f->systemd != NULL)
{
dbus_connection_remove_filter (f->systemd, systemd_filter, f);
test_connection_shutdown (f->ctx, f->systemd);
dbus_connection_close (f->systemd);
dbus_connection_unref (f->systemd);
f->systemd = NULL;
......@@ -1924,6 +1929,7 @@ teardown (Fixture *f,
if (f->activated != NULL)
{
dbus_connection_remove_filter (f->activated, activated_filter, f);
test_connection_shutdown (f->ctx, f->activated);
dbus_connection_close (f->activated);
dbus_connection_unref (f->activated);
f->activated = NULL;
......
......@@ -964,6 +964,7 @@ teardown (Fixture *f,
if (f->caller_filter_added)
dbus_connection_remove_filter (f->caller, caller_filter, f);
test_connection_shutdown (f->ctx, f->caller);
dbus_connection_close (f->caller);
dbus_connection_unref (f->caller);
f->caller = NULL;
......@@ -974,6 +975,7 @@ teardown (Fixture *f,
if (f->systemd_filter_added)
dbus_connection_remove_filter (f->systemd, systemd_filter, f);
test_connection_shutdown (f->ctx, f->systemd);
dbus_connection_close (f->systemd);
dbus_connection_unref (f->systemd);
f->systemd = NULL;
......@@ -984,6 +986,7 @@ teardown (Fixture *f,
if (f->activated_filter_added)
dbus_connection_remove_filter (f->activated, activated_filter, f);
test_connection_shutdown (f->ctx, f->activated);
dbus_connection_close (f->activated);
dbus_connection_unref (f->activated);
f->activated = NULL;
......
......@@ -201,6 +201,7 @@ teardown (Fixture *f,
if (f->conn != NULL)
{
test_connection_shutdown (f->ctx, f->conn);
dbus_connection_close (f->conn);
dbus_connection_unref (f->conn);
f->conn = NULL;
......
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