[tracker/wip/carlosg/rewrite-bus-impl: 3/5] libtracker-sparql: Reply earlier to D-Bus query messages in endpoints
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/rewrite-bus-impl: 3/5] libtracker-sparql: Reply earlier to D-Bus query messages in endpoints
- Date: Sun, 17 Jul 2022 13:02:08 +0000 (UTC)
commit 425411307ea0487279fb768dd69368da4ac59bd4
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).
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 e1b22cda9..f609adb52 100644
--- a/src/libtracker-sparql/tracker-endpoint-dbus.c
+++ b/src/libtracker-sparql/tracker-endpoint-dbus.c
@@ -439,13 +439,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]