diff options
author | Robin Burchell <robin.burchell@jollamobile.com> | 2013-12-20 19:34:06 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-30 23:20:40 +0100 |
commit | 82edcd4e12d2652d63ec0732d8053b2761562d3d (patch) | |
tree | abbd55eae67453b1307dda2adaabaf266cb79a0c /src/dbus | |
parent | 56d141ae6bd3fbb6b100307a7a251e2026147f60 (diff) |
Don't leak pending call objects when peer disconnects
Unlike in regular connection to DBus server, we don't get pending call
notifies when a peer drops the connection in peer-to-peer mode.
Thus, we need to keep track of pending calls in such cases and get rid of
them in ~QDBusConnectionPrivate().
Change-Id: I83e20db0bc7b2ebf509c7fdb1382ffc7d0ede9d3
Done-with: Kalle Vahlman <kalle.vahlman@movial.com>
Reviewed-by: Daniele E. Domenichelli <daniele.domenichelli@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusconnection_p.h | 2 | ||||
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 515eab6dfe..350e49a50d 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -178,6 +178,7 @@ public: typedef QMultiHash<QString, SignalHook> SignalHookHash; typedef QHash<QString, QDBusMetaObject* > MetaObjectHash; typedef QHash<QByteArray, int> MatchRefCountHash; + typedef QList<QDBusPendingCallPrivate*> PendingCallList; struct WatchedServiceData { WatchedServiceData() : refcount(0) {} @@ -316,6 +317,7 @@ public: MatchRefCountHash matchRefCounts; ObjectTreeNode rootNode; MetaObjectHash cachedMetaObjects; + PendingCallList pendingCalls; QMutex callDeliveryMutex; QDBusCallDeliveryEvent *callDeliveryState; // protected by the callDeliveryMutex mutex diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index d797fbfb99..77de09d197 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1092,6 +1092,9 @@ void QDBusConnectionPrivate::closeConnection() ; } } + + qDeleteAll(pendingCalls); + qDBusDebug() << this << "Disconnected"; } @@ -1834,6 +1837,8 @@ void QDBusConnectionPrivate::processFinishedCall(QDBusPendingCallPrivate *call) QMutexLocker locker(&call->mutex); + connection->pendingCalls.removeOne(call); + QDBusMessage &msg = call->replyMessage; if (call->pending) { // decode the message @@ -2094,6 +2099,10 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM pcall->pending = pending; q_dbus_pending_call_set_notify(pending, qDBusResultReceived, pcall, 0); + // DBus won't notify us when a peer disconnects so we need to track these ourselves + if (mode == QDBusConnectionPrivate::PeerMode) + pendingCalls.append(pcall); + return pcall; } else { // we're probably disconnected at this point |