+ if (G_UNLIKELY (_g_dbus_debug_transport ()))
+ {
+ _g_dbus_debug_print_lock ();
+ g_print ("========================================================================\n"
+ "GDBus-debug:Transport:\n"
+ " ---- READ ERROR on stream of type %s:\n"
+ " ---- %s %d: %s\n",
+ g_type_name (G_TYPE_FROM_INSTANCE (g_io_stream_get_input_stream (worker->stream))),
+ g_quark_to_string (error->domain), error->code,
+ error->message);
+ _g_dbus_debug_print_unlock ();
+ }
+
+ /* Every async read that uses this callback uses worker->cancellable
+ * as its GCancellable. worker->cancellable gets cancelled if and only
+ * if the GDBusConnection tells us to close (either via
+ * _g_dbus_worker_stop, which is called on last-unref, or directly),
+ * so a cancelled read must mean our connection was closed locally.
+ *
+ * If we're closing, other errors are possible - notably,
+ * G_IO_ERROR_CLOSED can be seen if we close the stream with an async
+ * read in-flight. It seems sensible to treat all read errors during
+ * closing as an expected thing that doesn't trip exit-on-close.
+ *
+ * Because close_expected can't be set until we get into the worker
+ * thread, but the cancellable is signalled sooner (from another
+ * thread), we do still need to check the error.
+ */
+ if (worker->close_expected ||
+ g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ _g_dbus_worker_emit_disconnected (worker, FALSE, NULL);
+ else
+ _g_dbus_worker_emit_disconnected (worker, TRUE, error);
+