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



commit c6862451411ae3039029fdd1e3697343fa2aed19
Author: Dan Winship <danw gnome org>
Date:   Wed Aug 19 13:21:00 2015 -0400

    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

 gio/gdbusmethodinvocation.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/gio/gdbusmethodinvocation.c b/gio/gdbusmethodinvocation.c
index 5bd850b..9d833e2 100644
--- a/gio/gdbusmethodinvocation.c
+++ b/gio/gdbusmethodinvocation.c
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]