[tracker/tracker-3.3] libtracker-sparql: Reply earlier to D-Bus query messages in endpoints



commit c3f53e4b6eb7d1a90dbb0e6981b3a273a314c277
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jul 17 01:28:36 2022 +0200

    libtracker-sparql: Reply earlier to D-Bus query messages in endpoints
    
    Currently, the endpoint waits to write the full cursor contents before
    replying to a Query D-Bus request. This relies on the caller side
    simultaneously issuing the D-Bus request and reading all data from
    the cursor, so that on the endpoint side writing the cursor does not
    end up blocking when the buffer grew too large.
    
    This relies on the bus TrackerSparqlConnection side doing exactly
    that, and splicing all cursor contents in a memory buffer, This is
    however not friendly to an approach using input streams, since the
    TrackerSparqlConnection side would read pipe contents incrementally
    while iterating the cursor, but it didn't get it yet since the
    endpoint will end up clogging the pipe and the Query request will
    not be replied.
    
    In order to fix this, reply the D-Bus request before writing the
    cursor contents, so that the other end can get ahead with creating
    a TrackerSparqlCursor that will stream the contents during iteration.
    
    As a result the errors happening during writes are not forwarded to
    the other end anymore, but since they would mostly consist of write
    errors, it sounds likely the other end had some involvement in that
    (e.g. dying or prematurely closing the cursor).
    
    (cherry-picked from commit 425411307ea0487279fb768dd69368da4ac59bd4)

 src/libtracker-sparql/tracker-endpoint-dbus.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-endpoint-dbus.c b/src/libtracker-sparql/tracker-endpoint-dbus.c
index c6735603d..917342563 100644
--- a/src/libtracker-sparql/tracker-endpoint-dbus.c
+++ b/src/libtracker-sparql/tracker-endpoint-dbus.c
@@ -432,13 +432,10 @@ handle_cursor_reply (GTask        *task,
        for (i = 0; i < n_columns; i++)
                variable_names[i] = tracker_sparql_cursor_get_variable_name (cursor, i);
 
-       write_cursor (request, cursor, &write_error);
-
-       if (write_error)
-               g_dbus_method_invocation_return_gerror (request->invocation, write_error);
-       else
-               g_dbus_method_invocation_return_value (request->invocation, g_variant_new ("(^as)", 
variable_names));
+       g_dbus_method_invocation_return_value (request->invocation, g_variant_new ("(^as)", variable_names));
 
+       if (!write_cursor (request, cursor, &write_error))
+               g_warning ("Endpoint failed to fully write cursor: %s\n", write_error->message);
        g_free (variable_names);
        g_clear_error (&write_error);
 


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