[tracker/wip/carlosg/automatic-store-shutdown: 3/5] libtracker-bus: Avoid pinging tracker-store on initialization
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/automatic-store-shutdown: 3/5] libtracker-bus: Avoid pinging tracker-store on initialization
- Date: Mon, 12 Nov 2018 10:50:58 +0000 (UTC)
commit 504bc49799b49f7477fa2aa0ff39e868c2b8dda5
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Nov 11 17:46:58 2018 +0100
libtracker-bus: Avoid pinging tracker-store on initialization
Avoid possibly raising tracker-store when initializating a bus
connection. This can be done in a delayed manner (eg. when some
other dbus message is sent in its way).
There is one situation where this is necessary though, the database
may not exist yet. In this case we must poke tracker-store before
setting up the direct connection. Detect those cases by handling
direct connection initialization errors.
src/libtracker-bus/tracker-bus.vala | 16 +++++++++-------
src/libtracker-sparql-backend/tracker-backend.vala | 18 ++++++++++++++----
tests/functional-tests/ipc/test-bus-query.vala | 2 +-
tests/functional-tests/ipc/test-bus-update.vala | 2 +-
4 files changed, 25 insertions(+), 13 deletions(-)
---
diff --git a/src/libtracker-bus/tracker-bus.vala b/src/libtracker-bus/tracker-bus.vala
index 3b971d030..a257c51c8 100644
--- a/src/libtracker-bus/tracker-bus.vala
+++ b/src/libtracker-bus/tracker-bus.vala
@@ -21,7 +21,7 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
DBusConnection bus;
string dbus_name;
- public Connection (string dbus_name, DBusConnection? dbus_connection) throws Sparql.Error, IOError,
DBusError, GLib.Error {
+ public Connection (string dbus_name, DBusConnection? dbus_connection, bool start) throws
Sparql.Error, IOError, DBusError, GLib.Error {
this.dbus_name = dbus_name;
if (dbus_connection == null)
@@ -29,14 +29,16 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
else
bus = dbus_connection;
- debug ("Waiting for service to become available...");
+ if (start) {
+ debug ("Waiting for service to become available...");
- // do not use proxy to work around race condition in GDBus
- // NB#259760
- var msg = new DBusMessage.method_call (dbus_name, Tracker.DBUS_OBJECT_STATUS,
Tracker.DBUS_INTERFACE_STATUS, "Wait");
- bus.send_message_with_reply_sync (msg, 0, /* timeout */ int.MAX, null).to_gerror ();
+ // do not use proxy to work around race condition in GDBus
+ // NB#259760
+ var msg = new DBusMessage.method_call (dbus_name, Tracker.DBUS_OBJECT_STATUS,
Tracker.DBUS_INTERFACE_STATUS, "Wait");
+ bus.send_message_with_reply_sync (msg, 0, /* timeout */ int.MAX, null).to_gerror ();
- debug ("Service is ready");
+ debug ("Service is ready");
+ }
// ensure that error domain is registered with GDBus
new Sparql.Error.INTERNAL ("");
diff --git a/src/libtracker-sparql-backend/tracker-backend.vala
b/src/libtracker-sparql-backend/tracker-backend.vala
index 7768d5f07..9de2e645c 100644
--- a/src/libtracker-sparql-backend/tracker-backend.vala
+++ b/src/libtracker-sparql-backend/tracker-backend.vala
@@ -193,12 +193,22 @@ class Tracker.Sparql.Backend : Connection {
switch (backend) {
case Backend.AUTO:
- bus = new Tracker.Bus.Connection (domain_ontology.get_domain ("Tracker1"),
global_dbus_connection);
+ bool direct_failed = false;
try {
direct = create_readonly_direct ();
- } catch (GLib.Error e) {
- warning ("Falling back to bus backend, the direct backend failed to
initialize: " + e.message);
+ } catch (DBInterfaceError e) {
+ direct_failed = true;
+ }
+
+ bus = new Tracker.Bus.Connection (domain_ontology.get_domain ("Tracker1"),
global_dbus_connection, direct_failed);
+
+ if (direct_failed) {
+ try {
+ direct = create_readonly_direct ();
+ } catch (DBInterfaceError e) {
+ warning ("Falling back to bus backend, the direct backend failed to
initialize: " + e.message);
+ }
}
break;
@@ -208,7 +218,7 @@ class Tracker.Sparql.Backend : Connection {
break;
case Backend.BUS:
- bus = new Tracker.Bus.Connection (domain_ontology.get_domain ("Tracker1"),
global_dbus_connection);
+ bus = new Tracker.Bus.Connection (domain_ontology.get_domain ("Tracker1"),
global_dbus_connection, false);
break;
default:
diff --git a/tests/functional-tests/ipc/test-bus-query.vala b/tests/functional-tests/ipc/test-bus-query.vala
index 997dc9e7c..4e51a2b07 100644
--- a/tests/functional-tests/ipc/test-bus-query.vala
+++ b/tests/functional-tests/ipc/test-bus-query.vala
@@ -5,7 +5,7 @@ int
main( string[] args )
{
try {
- TestApp app = new TestApp (new Tracker.Bus.Connection ("org.freedesktop.Tracker1", null));
+ TestApp app = new TestApp (new Tracker.Bus.Connection ("org.freedesktop.Tracker1", null,
true));
return app.run ();
} catch (GLib.Error e) {
diff --git a/tests/functional-tests/ipc/test-bus-update.vala b/tests/functional-tests/ipc/test-bus-update.vala
index 997dc9e7c..4e51a2b07 100644
--- a/tests/functional-tests/ipc/test-bus-update.vala
+++ b/tests/functional-tests/ipc/test-bus-update.vala
@@ -5,7 +5,7 @@ int
main( string[] args )
{
try {
- TestApp app = new TestApp (new Tracker.Bus.Connection ("org.freedesktop.Tracker1", null));
+ TestApp app = new TestApp (new Tracker.Bus.Connection ("org.freedesktop.Tracker1", null,
true));
return app.run ();
} catch (GLib.Error e) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]