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 (cherry picked from commit 3aafe9d5)
- asturmlechner 2023-04-10: Drop conflicting drive-by fix in socket autotest - version check does not exist at least in 5.15.9.