From: Simon McVittie Date: Thu, 12 Jul 2018 11:51:38 +0000 (+0100) Subject: tests: Detach most connections from main loop before closing X-Git-Tag: dbus-1.13.6~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8177bbcf5262724d9bc5538b81aa366a51fbd520;p=thirdparty%2Fdbus.git 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 Reviewed-by: Philip Withnall Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194 --- diff --git a/test/containers.c b/test/containers.c index eb7025229..245400516 100644 --- a/test/containers.c +++ b/test/containers.c @@ -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); } diff --git a/test/corrupt.c b/test/corrupt.c index be5314b40..758084a40 100644 --- a/test/corrupt.c +++ b/test/corrupt.c @@ -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; diff --git a/test/dbus-daemon-eavesdrop.c b/test/dbus-daemon-eavesdrop.c index be21d0ab4..6f4d9bb56 100644 --- a/test/dbus-daemon-eavesdrop.c +++ b/test/dbus-daemon-eavesdrop.c @@ -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; diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index b41533950..47d2c70d5 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -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); } diff --git a/test/fdpass.c b/test/fdpass.c index 1d8ee605f..d84b7fe99 100644 --- a/test/fdpass.c +++ b/test/fdpass.c @@ -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; diff --git a/test/internals/refs.c b/test/internals/refs.c index 89f581aa8..c0f751288 100644 --- a/test/internals/refs.c +++ b/test/internals/refs.c @@ -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); } diff --git a/test/loopback.c b/test/loopback.c index ad7e0e94a..f89f5a951 100644 --- a/test/loopback.c +++ b/test/loopback.c @@ -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); diff --git a/test/monitor.c b/test/monitor.c index 978ef30f3..eb11eb81d 100644 --- a/test/monitor.c +++ b/test/monitor.c @@ -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; diff --git a/test/sd-activation.c b/test/sd-activation.c index b5a08bceb..b60888aea 100644 --- a/test/sd-activation.c +++ b/test/sd-activation.c @@ -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; diff --git a/test/uid-permissions.c b/test/uid-permissions.c index 24f6f725e..b48ab0481 100644 --- a/test/uid-permissions.c +++ b/test/uid-permissions.c @@ -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;