[tracker] libtracker-sparql-backend: Work around race condition in GDBus



commit 3dcb743762e6272fe9d3643ca7e16414825c09d7
Author: Juerg Billeter <juerg debian bitron ch>
Date:   Wed May 25 15:49:50 2011 +0200

    libtracker-sparql-backend: Work around race condition in GDBus
    
    GDBusProxy created from a thread without its own GMainContext may cause
    memory corruption due to a race condition in handling the
    NameOwnerChanged signal.
    
    As we only call a single method on the Status object, drop use of
    GDBusProxy in this case and directly use low level D-Bus support.
    
    Fixes NB#254855.

 src/libtracker-sparql-backend/tracker-backend.vala |   25 ++++++++------------
 1 files changed, 10 insertions(+), 15 deletions(-)
---
diff --git a/src/libtracker-sparql-backend/tracker-backend.vala b/src/libtracker-sparql-backend/tracker-backend.vala
index 054a97a..0ac051b 100644
--- a/src/libtracker-sparql-backend/tracker-backend.vala
+++ b/src/libtracker-sparql-backend/tracker-backend.vala
@@ -17,11 +17,6 @@
  * Boston, MA  02110-1301, USA.
  */
 
-[DBus (name = "org.freedesktop.Tracker1.Status")]
-interface Tracker.Backend.Status : DBusProxy {
-	public abstract void wait () throws DBusError;
-}
-
 class Tracker.Sparql.Backend : Connection {
 	bool initialized;
 	Tracker.Sparql.Connection direct = null;
@@ -33,18 +28,18 @@ class Tracker.Sparql.Backend : Connection {
 	}
 
 	public Backend () throws Sparql.Error, IOError, DBusError, SpawnError {
-		Tracker.Backend.Status status = GLib.Bus.get_proxy_sync (BusType.SESSION,
-		                                                         TRACKER_DBUS_SERVICE,
-		                                                         TRACKER_DBUS_OBJECT_STATUS,
-		                                                         DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | DBusProxyFlags.DO_NOT_CONNECT_SIGNALS);
-		status.set_default_timeout (int.MAX);
+		try {
+			// Makes sure the sevice is available
+			debug ("Waiting for service to become available...");
 
-		// Makes sure the sevice is available
-		debug ("Waiting for service to become available...");
-		status.wait ();
-		debug ("Service is ready");
+			// do not use proxy to work around race condition in GDBus
+			// NB#259760
+			var bus = GLib.Bus.get_sync (BusType.SESSION);
+			var msg = new DBusMessage.method_call (TRACKER_DBUS_SERVICE, 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");
 
-		try {
 			debug ("Constructing connection, direct_only=%s", direct_only ? "true" : "false");
 			load_plugins (direct_only);
 			debug ("Backend is ready");



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