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

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

Git commit 009526ca22dc891a2ad2c7229e7f5d6aeac0769f by Till Adam.
Committed on 22/01/2013 at 15:49.
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    nepomuk/query/queryserviceclient.cpp

http://commits.kde.org/kdelibs/009526ca22dc891a2ad2c7229e7f5d6aeac0769f

diff --git a/nepomuk/query/queryserviceclient.cpp b/nepomuk/query/queryserviceclient.cpp
index 7d3ef0f..841308f 100644
--- a/nepomuk/query/queryserviceclient.cpp
+++ b/nepomuk/query/queryserviceclient.cpp
@@ -403,8 +403,15 @@ QList< Nepomuk::Query::Result > \
Nepomuk::Query::QueryServiceClient::syncDesktopQ  void \
Nepomuk::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