[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdesupport/akonadi/server/src/search
From:       David Faure <faure () kde ! org>
Date:       2010-02-09 10:53:58
Message-ID: 1265712838.400716.24175.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1087546 by dfaure:

And now the real fix for the dbus connection leak problem :/

Next step: doing the same (but not the same) in kdelibs/nepomuk.
But at least the akonadiserver leak (triggered by kmail) is fixed by this.

CCMAIL: release-team@kde.org


 M  +23 -10    queryserviceclient.cpp  


--- trunk/kdesupport/akonadi/server/src/search/queryserviceclient.cpp \
#1087545:1087546 @@ -40,21 +40,34 @@
     {
     public:
         QDBusConnectionPerThreadHelper()
-            : m_counter( 0 ) {
+            : m_connection( QDBusConnection::connectToBus(
+                                QDBusConnection::SessionBus,
+                                \
QString::fromLatin1("NepomukQueryServiceConnection%1").arg(newNumber()) ) ) +        \
{  }
-
-        QDBusConnection newConnection() {
-            QMutexLocker lock( &m_mutex );
-            return QDBusConnection::connectToBus( QDBusConnection::SessionBus,
-                                                  \
QString::fromLatin1("NepomukQueryServiceConnection%1").arg(++m_counter) ); +        \
~QDBusConnectionPerThreadHelper() { +            QDBusConnection::disconnectFromBus( \
m_connection.name() );  }
 
+        static QDBusConnection threadConnection();
+
     private:
-        int m_counter;
-        QMutex m_mutex;
+        int newNumber() {
+            return m_counter.fetchAndAddAcquire(1);
+        }
+        QAtomicInt m_counter;
+        QDBusConnection m_connection;
     };
 
-    Q_GLOBAL_STATIC(QDBusConnectionPerThreadHelper, \
s_globalDBusConnectionPerThreadHelper) +    \
QThreadStorage<QDBusConnectionPerThreadHelper *> s_perThreadConnection; +
+    QDBusConnection QDBusConnectionPerThreadHelper::threadConnection()
+    {
+        if (!s_perThreadConnection.hasLocalData()) {
+            s_perThreadConnection.setLocalData(new QDBusConnectionPerThreadHelper);
+        }
+        return s_perThreadConnection.localData()->m_connection;
+    }
 }
 
 
@@ -64,7 +77,7 @@
     Private()
         : queryServiceInterface( 0 ),
           queryInterface( 0 ),
-          dbusConnection( s_globalDBusConnectionPerThreadHelper()->newConnection() \
), +          dbusConnection( QDBusConnectionPerThreadHelper::threadConnection() ),
           loop( 0 ) {
     }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic