mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
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 <davidz@redhat.com>
This commit is contained in:
parent
ab6b6c68c5
commit
6d4ade4cf0
@ -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</link> 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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user