[tracker/wip/carlosg/perf-improvements: 2/5] libtracker-sparql: Handle write errors with DBus cursors



commit d9e6fb6e9f5dae4e5dd1df62fd34db7e89a75888
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Jun 3 17:32:59 2020 +0200

    libtracker-sparql: Handle write errors with DBus cursors
    
    Stop ASAP on errors like e.g. EPIPE, instead of stalling trying
    to write everything (unsuccessfully, anyway).

 src/libtracker-sparql/tracker-endpoint-dbus.c | 31 ++++++++++++++++++---------
 1 file changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-endpoint-dbus.c b/src/libtracker-sparql/tracker-endpoint-dbus.c
index 3630579e6..1ce98b00d 100644
--- a/src/libtracker-sparql/tracker-endpoint-dbus.c
+++ b/src/libtracker-sparql/tracker-endpoint-dbus.c
@@ -224,14 +224,18 @@ write_cursor (QueryRequest          *request,
        while (tracker_sparql_cursor_next (cursor, NULL, &inner_error)) {
                glong cur_offset = -1;
 
-               g_data_output_stream_put_int32 (request->data_stream, n_columns, NULL, NULL);
+               if (!g_data_output_stream_put_int32 (request->data_stream, n_columns,
+                                                    NULL, &inner_error))
+                       break;
 
                for (i = 0; i < n_columns; i++) {
                        glong len;
 
-                       g_data_output_stream_put_int32 (request->data_stream,
-                                                       tracker_sparql_cursor_get_value_type (cursor, i),
-                                                       NULL, NULL);
+                       if (!g_data_output_stream_put_int32 (request->data_stream,
+                                                            tracker_sparql_cursor_get_value_type (cursor, i),
+                                                            NULL, &inner_error))
+                               goto out;
+
                        values[i] = tracker_sparql_cursor_get_string (cursor, i, &len);
                        len++;
                        cur_offset += len;
@@ -239,18 +243,25 @@ write_cursor (QueryRequest          *request,
                }
 
                for (i = 0; i < n_columns; i++) {
-                       g_data_output_stream_put_int32 (request->data_stream,
-                                                       offsets[i], NULL, NULL);
+                       if (!g_data_output_stream_put_int32 (request->data_stream,
+                                                            offsets[i], NULL, &inner_error))
+                               goto out;
                }
 
                for (i = 0; i < n_columns; i++) {
-                       g_data_output_stream_put_string (request->data_stream,
-                                                        values[i] ? values[i] : "",
-                                                        NULL, NULL);
-                       g_data_output_stream_put_byte (request->data_stream, 0, NULL, NULL);
+                       if (!g_data_output_stream_put_string (request->data_stream,
+                                                             values[i] ? values[i] : "",
+                                                             NULL, &inner_error))
+                               goto out;
+
+                       if (!g_data_output_stream_put_byte (request->data_stream, 0, NULL,
+                                                           &inner_error))
+                               goto out;
                }
        }
 
+out:
+
        g_free (values);
        g_free (offsets);
 


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