summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/socket
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2021-01-23 13:00:22 +0200
committerAlex Trotsenko <alex1973tr@gmail.com>2021-03-02 22:53:06 +0200
commitf265c87e015c26225b80297f5c9f430ea7030214 (patch)
tree29e7fedb3e6e51e0cc634852079e998c8705a921 /tests/auto/network/socket
parentd316ae8e830b8b86f81307d35583f20773da6a55 (diff)
Allow QWindowsPipe{Reader|Writer} to work with foreign event loops, take 2
When a foreign event loop that does not enter an alertable wait state is running (which is also the case when a native dialog window is modal), pipe handlers would freeze temporarily due to their APC callbacks not being invoked. We address this problem by moving the I/O callbacks to the Windows thread pool, and only posting completion events to the main loop from there. That makes the actual I/O completely independent from any main loop, while the signal delivery works also with foreign loops (because Qt event delivery uses Windows messages, which foreign loops typically handle correctly). As a nice side effect, performance (and in particular scalability) is improved. Several other approaches have been tried: 1) Using QWinEventNotifier was about a quarter slower and scaled much worse. Additionally, it also required a rather egregious hack to handle the (pathological) case of a single thread talking to both ends of a QLocalSocket synchronously. 2) Queuing APCs from the thread pool to the main thread and also posting wake-up events to its event loop, and handling I/O on the main thread; this performed roughly like this solution, but scaled half as well, and the separate wake-up path was still deemed hacky. 3) Only posting wake-up events to the main thread from the thread pool, and still handling I/O on the main thread; this still performed comparably to 2), and the pathological case was not handled at all. 4) Using this approach for reads and that of 3) for writes was slightly faster with big amounts of data, but scaled slightly worse, and the diverging implementations were deemed not desirable. Fixes: QTBUG-64443 Change-Id: I66443c3021d6ba98639a214c3e768be97d2cf14b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'tests/auto/network/socket')
-rw-r--r--tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp20
1 files changed, 0 insertions, 20 deletions
diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
index c99ca990da..8b2b4ea4da 100644
--- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
@@ -639,26 +639,6 @@ void tst_QLocalSocket::readBufferOverflow()
QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize));
// no more bytes available
QCOMPARE(client.bytesAvailable(), 0);
-
-#ifdef Q_OS_WIN
- serverSocket->write(buffer, readBufferSize);
- QVERIFY(serverSocket->waitForBytesWritten());
-
- // ensure the read completion routine is called
- SleepEx(100, true);
- QVERIFY(client.waitForReadyRead());
- QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize));
-
- // Test overflow caused by an asynchronous pipe operation.
- client.setReadBufferSize(1);
- serverSocket->write(buffer, 2);
-
- QVERIFY(client.waitForReadyRead());
- // socket disconnects, if there any error on pipe
- QCOMPARE(client.state(), QLocalSocket::ConnectedState);
- QCOMPARE(client.bytesAvailable(), qint64(2));
- QCOMPARE(client.read(buffer, 2), qint64(2));
-#endif
}
static qint64 writeCommand(const QVariant &command, QIODevice *device, int commandCounter)