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

List:       kde-commits
Subject:    [nepomuk-core/KDE/4.10] libnepomukcore/query: Cancel in-flight dbus queries to avoid leaks.
From:       Till Adam <till () kdab ! com>
Date:       2013-01-25 17:14:25
Message-ID: 20130125171425.C45EFA6091 () git ! kde ! org
[Download RAW message or body]

Git commit d9d9e43c562ef13e40ed5d37f06f2f34d902e21f by Till Adam.
Committed on 25/01/2013 at 18:11.
Pushed by tilladam into branch 'KDE/4.10'.

Cancel in-flight dbus queries to avoid leaks.

If close() is called on the query service client while dbus queries are
still in flight, they were left dangling. This change makes sure they
are properly cancelled. Without this, all such dangling queries are
maintained by nepomuk and updated constantly, causing extreme loads,
over time.

REVIEW: 108550

M  +9    -2    libnepomukcore/query/queryserviceclient.cpp

http://commits.kde.org/nepomuk-core/d9d9e43c562ef13e40ed5d37f06f2f34d902e21f

diff --git a/libnepomukcore/query/queryserviceclient.cpp \
b/libnepomukcore/query/queryserviceclient.cpp index 10ae928..ac3e1d0 100644
--- a/libnepomukcore/query/queryserviceclient.cpp
+++ b/libnepomukcore/query/queryserviceclient.cpp
@@ -404,8 +404,15 @@ QList< Nepomuk2::Query::Result > \
Nepomuk2::Query::QueryServiceClient::syncDeskto  void \
Nepomuk2::Query::QueryServiceClient::close()  {
     // drop pending query calls
-    // TODO: This could lead to dangling queries in the service when close is called \
                before the pending call has returned!!!
-    //       We could also use a stack of pending calls or something like that.
+
+    // in case we fired a query but it did not return yet, cancel it
+    if (d->m_pendingCallWatcher && !d->queryInterface) {
+        QDBusPendingReply<QDBusObjectPath> reply = *(d->m_pendingCallWatcher);
+        OrgKdeNepomukQueryInterface interface( d->queryServiceInterface->service(),
+                                               reply.value().path(),
+                                               d->dbusConnection );
+        interface.close();
+    }
     delete d->m_pendingCallWatcher;
 
     d->m_errorMessage.truncate(0);


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

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