BlueZ: Fix leaking client socket when running QLEController Peripheral mode
In fact there are two socket leaks. The first is the socket for the incoming l2cp connection from the central device and the second one is allocated in the ctor of QBluetoothSocket. When QBluetoothSocket::setSocketDescriptor is called the previously ctor allocated socket was simply ignorred. This patch closes both socket. Fixes: QTBUG-75278 Change-Id: Ia483e3c2a04bec3a53ddf744c22b794941edf848 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
14b0efe1d4
commit
d67ca376b2
|
|
@ -674,6 +674,9 @@ bool QBluetoothSocketPrivateBluez::setSocketDescriptor(int socketDescriptor, QBl
|
||||||
connectWriteNotifier = nullptr;
|
connectWriteNotifier = nullptr;
|
||||||
|
|
||||||
socketType = socketType_;
|
socketType = socketType_;
|
||||||
|
if (socket != -1)
|
||||||
|
QT_CLOSE(socket);
|
||||||
|
|
||||||
socket = socketDescriptor;
|
socket = socketDescriptor;
|
||||||
|
|
||||||
// ensure that O_NONBLOCK is set on new connections.
|
// ensure that O_NONBLOCK is set on new connections.
|
||||||
|
|
|
||||||
|
|
@ -3115,6 +3115,14 @@ void QLowEnergyControllerPrivateBluez::handleConnectionRequest()
|
||||||
if (connectionHandle == 0)
|
if (connectionHandle == 0)
|
||||||
qCWarning(QT_BT_BLUEZ) << "Received client connection, but no connection complete event";
|
qCWarning(QT_BT_BLUEZ) << "Received client connection, but no connection complete event";
|
||||||
|
|
||||||
|
if (l2cpSocket) {
|
||||||
|
disconnect(l2cpSocket);
|
||||||
|
if (l2cpSocket->isOpen())
|
||||||
|
l2cpSocket->close();
|
||||||
|
|
||||||
|
l2cpSocket->deleteLater();
|
||||||
|
l2cpSocket = nullptr;
|
||||||
|
}
|
||||||
closeServerSocket();
|
closeServerSocket();
|
||||||
|
|
||||||
QBluetoothSocketPrivateBluez *rawSocketPrivate = new QBluetoothSocketPrivateBluez();
|
QBluetoothSocketPrivateBluez *rawSocketPrivate = new QBluetoothSocketPrivateBluez();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue