gdbus: don't warn when returning a value on a closed connection

g_dbus_method_invocation_return_value(), etc, don't have GError
parameters (which makes sense since they won't usually return errors,
and there's not much you could do if they did), so in the rare case
when something does go wrong, they print a warning.

However, there is at least one situation where the warning is a bad
idea: if you are using private bus connections, and a client connects,
makes a request, and then disconnects before getting the response.
Given that there's nothing the caller can do to prevent this case from
getting hit (since the client might not disconnect until after the
call to g_dbus_method_invocation_return_value() starts) and given that
the server can never actually know for sure that the client has
received the response (it might disconnect after reading the response,
but before processing it), just kill the warning in this case.

https://bugzilla.gnome.org/show_bug.cgi?id=753839
This commit is contained in:
Dan Winship 2015-08-19 13:21:00 -04:00
parent fc38156cba
commit c686245141

View File

@ -505,7 +505,8 @@ g_dbus_method_invocation_return_value_internal (GDBusMethodInvocation *invocatio
error = NULL;
if (!g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, &error))
{
g_warning ("Error sending message: %s", error->message);
if (!g_error_matches (G_IO_ERROR, G_IO_ERROR_CLOSED))
g_warning ("Error sending message: %s", error->message);
g_error_free (error);
}
g_object_unref (reply);