[tracker/wip/carlosg/fts-error-propagation: 1/4] libtracker-sparql: Fix race condition in tracker_sparql_connection_bus_new()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/fts-error-propagation: 1/4] libtracker-sparql: Fix race condition in tracker_sparql_connection_bus_new()
- Date: Sun, 21 Mar 2021 20:53:03 +0000 (UTC)
commit f3a02698855f37226045192a9ffb4558a1e2d3ae
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Mar 14 12:20:24 2021 +0100
libtracker-sparql: Fix race condition in tracker_sparql_connection_bus_new()
When commit cad0aefa0b added tracker_sparql_connection_bus_new_async(), it
made the sync variant run over the async variant for simplicity, using a
nested main loop that takes control until the asynchronous method returns.
However, we were using either of the thread default context, or the main
default one, in case of this call happening on a separate thread, this main
context may be iterating somewhere else, so the asynchronous method might
return before we've blocked on the main loop.
We want to lock the bus connection creation on this thread, so create a
new main context that is temporarily made the thread default, this will
ensure the asynchronous call is ensured to happen in our own thread, under
our own main loop.
src/libtracker-sparql/tracker-backend.vala | 2 ++
1 file changed, 2 insertions(+)
---
diff --git a/src/libtracker-sparql/tracker-backend.vala b/src/libtracker-sparql/tracker-backend.vala
index ae6313118..590dc76f2 100644
--- a/src/libtracker-sparql/tracker-backend.vala
+++ b/src/libtracker-sparql/tracker-backend.vala
@@ -43,8 +43,10 @@ public static Tracker.Sparql.Connection tracker_sparql_connection_bus_new (strin
} catch (Error e) {
error = e;
}
+
loop.quit();
});
+
loop.run ();
context.pop_thread_default ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]