]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
tests: Detach most connections from main loop before closing
authorSimon McVittie <smcv@collabora.com>
Thu, 12 Jul 2018 11:51:38 +0000 (12:51 +0100)
committerSimon McVittie <smcv@collabora.com>
Thu, 2 Aug 2018 16:16:43 +0000 (17:16 +0100)
We don't need to do this for connections that were never set up
with the main loop.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194

test/containers.c
test/corrupt.c
test/dbus-daemon-eavesdrop.c
test/dbus-daemon.c
test/fdpass.c
test/internals/refs.c
test/loopback.c
test/monitor.c
test/sd-activation.c
test/uid-permissions.c

index eb7025229c829ef7e061fd2b8dd1fc49a34ff76c..245400516868b5f8ed36c01fd42d0a26d809c7a9 100644 (file)
@@ -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);
     }
 
index be5314b4075e12f43a54c5bee1bdfa81fb88a321..758084a40c572d55bbec794b000ea271eb9d3b8e 100644 (file)
@@ -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;
index be21d0ab4da936e34f77620a47575ae876aa43bc..6f4d9bb56ecb1bae1561217dc25512f481929efa 100644 (file)
@@ -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;
index b4153395056eae021a05fc38bf70231d8c4eebf5..47d2c70d5407d5be9e789c6e7ea838a96ac05919 100644 (file)
@@ -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);
     }
 
index 1d8ee605f5dff3d52673d1f0b747ae0dcd3356f0..d84b7fe9912dfda08ad72725aea6acef2efcaded 100644 (file)
@@ -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;
index 89f581aa89d319303d2f9a0966c9192ed047b25e..c0f751288a5edfaaeb597997fbfe495d3cec6fd5 100644 (file)
@@ -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);
     }
index ad7e0e94ae59cfbd1ca4bfa2c83980ae1a6cd684..f89f5a9512709d1ff594083bcccd73d50e9fbf26 100644 (file)
@@ -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);
index 978ef30f3ea95bd207c6aae0e41407508a4aa9cc..eb11eb81d87f7d2a8a9a7fdf5746c0ce8941e5f9 100644 (file)
@@ -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;
index b5a08bcebc533e63cd6e4fcd2562cdd9f8c4ff60..b60888aea1559c3ddf040a6db8149e075c3d11b5 100644 (file)
@@ -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;
index 24f6f725e2110168e3254a803229dcc375b54154..b48ab04814f8bc4ecb5bf2b130bd37b36021af1b 100644 (file)
@@ -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;