gdbus: don't send unexpected replies

gdbus sets NO_REPLY_EXPECTED when no callback is given to
g_dbus_connection_call(). It makes sense that it also handles the server
side correctly by discarding replies to clients that don't want one.

https://bugzilla.gnome.org/show_bug.cgi?id=755421
This commit is contained in:
Lars Uebernickel 2015-10-30 11:24:19 +01:00 committed by Allison Ryan Lortie
parent 5dbb3453d7
commit dbea81b02d

View File

@ -394,6 +394,16 @@ g_dbus_method_invocation_return_value_internal (GDBusMethodInvocation *invocatio
g_return_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation));
g_return_if_fail ((parameters == NULL) || g_variant_is_of_type (parameters, G_VARIANT_TYPE_TUPLE));
if (g_dbus_message_get_flags (invocation->message) & G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED)
{
if (parameters != NULL)
{
g_variant_ref_sink (parameters);
g_variant_unref (parameters);
}
goto out;
}
if (parameters == NULL)
parameters = g_variant_new_tuple (NULL, 0);
@ -747,6 +757,9 @@ g_dbus_method_invocation_return_dbus_error (GDBusMethodInvocation *invocation,
g_return_if_fail (error_name != NULL && g_dbus_is_name (error_name));
g_return_if_fail (error_message != NULL);
if (g_dbus_message_get_flags (invocation->message) & G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED)
goto out;
if (G_UNLIKELY (_g_dbus_debug_return ()))
{
_g_dbus_debug_print_lock ();
@ -773,5 +786,6 @@ g_dbus_method_invocation_return_dbus_error (GDBusMethodInvocation *invocation,
g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
g_object_unref (reply);
out:
g_object_unref (invocation);
}