Fix a crash when a client connects and disconnects without sending any data.

The guard for forcing the client to send data within 10 seconds after connecting
hadn't been stopped again if the client disconnects on it's own.
This commit is contained in:
Michael Zanetti 2019-04-12 18:09:51 +02:00
parent 4e4ed7bad5
commit 681e538306

View File

@ -173,7 +173,7 @@ void MqttServerPrivate::onClientConnected(QSslSocket *client)
// Start a 10 second timer to clean up the connection if we don't get data until then.
QTimer *timeoutTimer = new QTimer(this);
connect(timeoutTimer, &QTimer::timeout, this, [this, client]() {
connect(timeoutTimer, &QTimer::timeout, client, [this, client]() {
qCWarning(dbgServer) << "A client connected but did not send data in 10 seconds. Dropping connection.";
client->abort();
pendingConnections.take(client)->deleteLater();
@ -228,6 +228,9 @@ void MqttServerPrivate::cleanupClient(QTcpSocket *client)
if (clientServerMap.contains(client)) {
clientServerMap.remove(client);
}
if (pendingConnections.contains(client)) {
delete pendingConnections.take(client);
}
if (clientList.contains(client)) {
ClientContext *ctx = clientList.value(client);
qCDebug(dbgServer) << "Client" << ctx->clientId << "disconnected.";