From b93dc2756d9947236deb955634b499b27aaaa414 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 28 Jun 2017 16:21:01 +0200 Subject: Fix concurrent access to QBluetoothSocket::canReadLine() on Android On Android, the socket's read buffer is managed in the Java thread. QBluetoothSocket::canReadLine() is public API (most likely) being called by in the main Qt thread though. The function directly called into the Java buffer instance without proper locking. This can create race conditions. Starting with this patch canReadLine() calls another QBluetoothSocketPrivate indirection to allow a platform specific implementation. This affects WinRT, BlueZ and the dummy backend too. This is not an issue on macOS as its implementation of QBluetoothSocket is separate and does not have to deal with multiple QBluetoothSocketPrivate implementations. Task-number: QTBUG-58190 Task-number: QTBUG-60830 Change-Id: Idae19f1aee6f809699d36519b01a3c68ad9c563d Reviewed-by: Qt CI Bot Reviewed-by: Oliver Wolff --- src/bluetooth/qbluetoothsocket_winrt.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/bluetooth/qbluetoothsocket_winrt.cpp') diff --git a/src/bluetooth/qbluetoothsocket_winrt.cpp b/src/bluetooth/qbluetoothsocket_winrt.cpp index 1f4e6233..a56e10fa 100644 --- a/src/bluetooth/qbluetoothsocket_winrt.cpp +++ b/src/bluetooth/qbluetoothsocket_winrt.cpp @@ -569,6 +569,11 @@ qint64 QBluetoothSocketPrivate::bytesAvailable() const return buffer.size(); } +bool QBluetoothSocketPrivate::canReadLine() const +{ + return buffer.canReadLine(); +} + void QBluetoothSocketPrivate::handleNewData(const QVector &data) { // Defer putting the data into the list until the next event loop iteration -- cgit v1.2.3