corrupt test: close connection before releasing GSocket
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 2 Sep 2013 16:14:38 +0000 (17:14 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 3 Sep 2013 11:00:37 +0000 (12:00 +0100)
GSocket takes responsibility for closing the fd, and there doesn't
seem to be any way to tell it not to. When this test is adapted to run
under DBusLoop as an alternative to dbus-glib, that becomes a problem,
because DBusLoop/DBusSocketSetEpoll do not tolerate that. Work around it.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
test/corrupt.c

index 0249590..be0e022 100644 (file)
@@ -246,6 +246,16 @@ test_corrupt (Fixture *f,
       "/org/freedesktop/DBus/Local");
 
   dbus_message_unref (incoming);
+
+  /* Free the DBusConnection before the GSocket, because GSocket is
+   * going to close our fd. GSocket tolerates closing an already-closed
+   * fd, whereas DBusLoop + DBusSocketSetEpoll doesn't. On Unix
+   * we could use dup() but that isn't portable to Windows :-(
+   */
+  dbus_connection_close (f->server_conn);
+  dbus_connection_unref (f->server_conn);
+  f->server_conn = NULL;
+
   g_object_unref (socket);
 }
 
@@ -325,6 +335,12 @@ test_byte_order (Fixture *f,
       "/org/freedesktop/DBus/Local");
 
   dbus_message_unref (message);
+
+  /* Free the DBusConnection before the GSocket, as above. */
+  dbus_connection_close (f->server_conn);
+  dbus_connection_unref (f->server_conn);
+  f->server_conn = NULL;
+
   g_object_unref (socket);
 }