summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@insta.fi>2022-05-13 07:48:40 +0300
committerJuha Vuolle <juha.vuolle@insta.fi>2022-05-30 09:13:23 +0300
commit3aafe9d5ce117858143dbb527f742cf875aa83e8 (patch)
treea66f2a5e4f89ec3d8eca065b7a4c5ebb7a84a4c2 /tests
parent502544ad96c83b9e793e7b0e41a632477ddc002c (diff)
Close socket descriptor when QBluetoothSocketBluez is destroyed
There are two private QBluetoothSocket backends on Linux: - QBluetoothSocketBluez is native linux socket implementation It is always used by the linux QBluetoothServer, and by QBluetoothSocket if Bluez version is < 5.46 - QBluetoothSocketBluezDbus used by QBluetoothSocket when Bluez >= 5.46 Leaving the native socket unclosed leaks the resource and eventually we may run out of descriptors. This is reproducible by creating and destroying QBluetoothServer instances in a loop. As a related drive-by: - Fix bluetooth socket autotest version check. DBus socket is used with bluez 5.46+ (for clarity: DBus lowenergycontroller is used with bluez 5.42+). This is needed for the test to pass with Bluez < 5.46 - Add a clarifying comment on socket close() Fixes: QTBUG-103067 Pick-to: 5.15 6.2 6.3 Change-Id: Idc38c743be09e559ea82bf09c2f9e44e4b80d666 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
index 455e31bb..23e291de 100644
--- a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+++ b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
@@ -518,7 +518,7 @@ void tst_QBluetoothSocket::tst_preferredSecurityFlags()
#elif QT_CONFIG(bluez)
// The bluezdbus socket uses "NoSecurity" by default, whereas the non-dbus bluez
// socket uses "Authorization" by default
- if (bluetoothdVersion() >= QVersionNumber(5, 42))
+ if (bluetoothdVersion() >= QVersionNumber(5, 46))
QCOMPARE(socket.preferredSecurityFlags(), QBluetooth::Security::NoSecurity);
else
QCOMPARE(socket.preferredSecurityFlags(), QBluetooth::Security::Authorization);
@@ -569,7 +569,7 @@ void tst_QBluetoothSocket::tst_unsupportedProtocolError()
QCOMPARE(errorSpy.size(), 1);
#if QT_CONFIG(bluez)
// Bluez dbus socket does not support connecting to port and gives different error code
- if (bluetoothdVersion() >= QVersionNumber(5, 42)) {
+ if (bluetoothdVersion() >= QVersionNumber(5, 46)) {
QCOMPARE(errorSpy.takeFirst().at(0).toInt(),
int(QBluetoothSocket::SocketError::ServiceNotFoundError));
} else {