From: David Zeuthen Date: Tue, 29 Jun 2010 19:19:56 +0000 (-0400) Subject: Bug 623143 – Never require non-closed connections X-Git-Tag: 2.25.11~126 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d4ade4cf0d6ed64ce59f3db4f270be08a4478fd;p=platform%2Fupstream%2Fglib.git Bug 623143 – Never require non-closed connections There's a couple of places in GDBus where it's a programming error (e.g. we'll assert or spew via e.g. g_warning()) to use the API on a closed connection. This approach can never work since a GDBusConnection can be closed at any point in time outside of programmer control. Just change the code to return a run-time error (e.g. return G_IO_ERROR_CLOSED when sending messages, invoking methods) or silently accept the request (e.g. exporting objects, registering for signals) without doing anything. Note that a GDBusConnection object is always useless after being closed - e.g. there's no way to "reopen" a connection - the user will have to create a new object and use that instead. https://bugzilla.gnome.org/show_bug.cgi?id=623143 Signed-off-by: David Zeuthen --- diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c index d80dfc0..98f705e 100644 --- a/gio/gdbusconnection.c +++ b/gio/gdbusconnection.c @@ -2574,9 +2574,6 @@ is_signal_data_for_name_lost_or_acquired (SignalData *signal_data) * linkend="g-main-context-push-thread-default">thread-default main * loop of the thread you are calling this method from. * - * It is considered a programming error to use this function if - * @connection is closed. - * * If @connection is not a message bus connection, @sender must be * %NULL. * @@ -2619,7 +2616,6 @@ g_dbus_connection_signal_subscribe (GDBusConnection *connection, */ g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), 0); - g_return_val_if_fail (!g_dbus_connection_is_closed (connection), 0); g_return_val_if_fail (sender == NULL || (g_dbus_is_name (sender) && (connection->priv->flags & G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION)), 0); g_return_val_if_fail (interface_name == NULL || g_dbus_is_interface_name (interface_name), 0); g_return_val_if_fail (member == NULL || g_dbus_is_member_name (member), 0); @@ -4096,7 +4092,6 @@ g_dbus_connection_register_object (GDBusConnection *connection, guint ret; g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), 0); - g_return_val_if_fail (!g_dbus_connection_is_closed (connection), 0); g_return_val_if_fail (object_path != NULL && g_variant_is_object_path (object_path), 0); g_return_val_if_fail (introspection_data != NULL, 0); g_return_val_if_fail (g_dbus_is_interface_name (introspection_data->name), 0); diff --git a/gio/gdbusnameowning.c b/gio/gdbusnameowning.c index ba3afb9..2cdb0a7 100644 --- a/gio/gdbusnameowning.c +++ b/gio/gdbusnameowning.c @@ -450,7 +450,7 @@ connection_get_cb (GObject *source_object, /** * g_bus_own_name_on_connection: - * @connection: A #GDBusConnection that is not closed. + * @connection: A #GDBusConnection. * @name: The well-known name to own. * @flags: A set of flags from the #GBusNameOwnerFlags enumeration. * @name_acquired_handler: Handler to invoke when @name is acquired or %NULL. @@ -478,7 +478,6 @@ g_bus_own_name_on_connection (GDBusConnection *connection, Client *client; g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), 0); - g_return_val_if_fail (!g_dbus_connection_is_closed (connection), 0); g_return_val_if_fail (g_dbus_is_name (name) && !g_dbus_is_unique_name (name), 0); G_LOCK (lock); @@ -766,7 +765,7 @@ g_bus_own_name_with_closures (GBusType bus_type, /** * g_bus_own_name_on_connection_with_closures: - * @connection: A #GDBusConnection that is not closed. + * @connection: A #GDBusConnection. * @name: The well-known name to own. * @flags: A set of flags from the #GBusNameOwnerFlags enumeration. * @name_acquired_closure: (allow-none): #GClosure to invoke when @name is diff --git a/gio/gdbusnamewatching.c b/gio/gdbusnamewatching.c index 0e131fb..dcf3af9 100644 --- a/gio/gdbusnamewatching.c +++ b/gio/gdbusnamewatching.c @@ -590,7 +590,7 @@ g_bus_watch_name (GBusType bus_type, /** * g_bus_watch_name_on_connection: - * @connection: A #GDBusConnection that is not closed. + * @connection: A #GDBusConnection. * @name: The name (well-known or unique) to watch. * @flags: Flags from the #GBusNameWatcherFlags enumeration. * @name_appeared_handler: Handler to invoke when @name is known to exist or %NULL. @@ -761,7 +761,7 @@ g_bus_watch_name_with_closures (GBusType bus_type, /** * g_bus_watch_name_on_connection_with_closures: - * @connection: A #GDBusConnection that is not closed. + * @connection: A #GDBusConnection. * @name: The name (well-known or unique) to watch. * @flags: Flags from the #GBusNameWatcherFlags enumeration. * @name_appeared_closure: (allow-none): #GClosure to invoke when @name is known