diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-12-29 17:14:18 -0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-09-15 02:08:34 +0000 |
commit | 939b7c630d3f51224eacb6596f0ea2267ca5bfe5 (patch) | |
tree | 87bbbce734686809267a439cd8a8544ad6783ac5 /tests/auto/dbus | |
parent | edaf7c30d43e82e662129f55343930f54199ec60 (diff) |
Implement the blocking QtDBus call in terms of the non-blocking one
This simplifies the code a little by having a single code path. More
importantly, we no longer need to call the evil function
dbus_connection_send_with_reply_and_block. That function acquires a lock
on the socket transport inside libdbus-1, which means all threads need
to wait until the one call gets unblocked before they can continue.
To do that, this commit reimplements the QDBus::Block part of
QDBusConnectionPrivate::sendWithReply by reusing the existing call to
sendWithReplyAsync() and then doing a blocking-wait with
QDBusPendingCallPrivate::waitForFinished().
By using (Q)DBusPendingCall and the threaded connection approach (next
commit), now we never block on the socket. That also means the code to
call dbus_pending_call_block() is no longer necessary and the
waitForFinished() function itself can be considerably simplified.
As a side-effect of no longer blocking, a number of pre-existing race
conditions that used to be hidden showed up.
Note: this commit deadlocks without the threading (next commits).
Task-number: QTBUG-43585
Change-Id: Ic5d393bfd36e48a193fcffff13b73754954a3f7d
Reviewed-by: Albert Astals Cid <aacid@kde.org>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests/auto/dbus')
-rw-r--r-- | tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index d85e842a23..4e04e4dbab 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Intel Corporation. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -525,6 +526,7 @@ public slots: QVERIFY(isConnected()); QVERIFY(c.isConnected()); QVERIFY(registerObject(c)); + QTestEventLoop::instance().exitLoop(); } private: @@ -552,11 +554,14 @@ void tst_QDBusConnection::registerObjectPeer() MyServer server(path); QDBusConnection::connectToPeer(server.address(), "beforeFoo"); + QTestEventLoop::instance().enterLoop(2); + QVERIFY(!QTestEventLoop::instance().timeout()); { QDBusConnection con = QDBusConnection::connectToPeer(server.address(), "foo"); - QCoreApplication::processEvents(); + QTestEventLoop::instance().enterLoop(2); + QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(con.isConnected()); MyObject obj; @@ -565,6 +570,7 @@ void tst_QDBusConnection::registerObjectPeer() } QDBusConnection::connectToPeer(server.address(), "afterFoo"); + QTestEventLoop::instance().enterLoop(2); { QDBusConnection con("foo"); @@ -713,6 +719,7 @@ public slots: m_conn = c; QVERIFY(isConnected()); QVERIFY(m_conn.isConnected()); + QTestEventLoop::instance().exitLoop(); } private: @@ -724,7 +731,8 @@ void tst_QDBusConnection::registerObjectPeer2() { MyServer2 server; QDBusConnection con = QDBusConnection::connectToPeer(server.address(), "foo"); - QCoreApplication::processEvents(); + QTestEventLoop::instance().enterLoop(2); + QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(con.isConnected()); QDBusConnection srv_con = server.connection(); @@ -879,6 +887,8 @@ void tst_QDBusConnection::registerQObjectChildrenPeer() { MyServer2 server; QDBusConnection con = QDBusConnection::connectToPeer(server.address(), "foo"); + QTestEventLoop::instance().enterLoop(2); + QVERIFY(!QTestEventLoop::instance().timeout()); QCoreApplication::processEvents(); QVERIFY(con.isConnected()); |