[glib] gdbus: don't send unexpected replies
- From: Allison Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gdbus: don't send unexpected replies
- Date: Wed, 13 Jan 2016 15:46:33 +0000 (UTC)
commit dbea81b02dc17f3e1935cdeb712d2728e3386812
Author: Lars Uebernickel <lars uebernickel canonical com>
Date: Fri Oct 30 11:24:19 2015 +0100
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
gio/gdbusmethodinvocation.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/gio/gdbusmethodinvocation.c b/gio/gdbusmethodinvocation.c
index 91a7e39..85e8811 100644
--- a/gio/gdbusmethodinvocation.c
+++ b/gio/gdbusmethodinvocation.c
@@ -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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]