mirror of https://github.com/nymea/nymea-mqtt
Fix a warning and improve debug print when a client times out
Old code would implicitly delete the client by the call to abort() as well as scheduling a deleteLater() which caused a unexpeted null receiver warning.improve-client-timeout
parent
fe76cb2d4b
commit
c6d5364300
|
|
@ -231,10 +231,9 @@ void MqttServerPrivate::onClientConnected(MqttServerClient *client)
|
||||||
// Start a 10 second timer to clean up the connection if we don't get data until then.
|
// Start a 10 second timer to clean up the connection if we don't get data until then.
|
||||||
QTimer *timeoutTimer = new QTimer(this);
|
QTimer *timeoutTimer = new QTimer(this);
|
||||||
connect(timeoutTimer, &QTimer::timeout, client, [this, client]() {
|
connect(timeoutTimer, &QTimer::timeout, client, [this, client]() {
|
||||||
qCWarning(dbgServer) << "A client connected but did not send data in 10 seconds. Dropping connection.";
|
qCWarning(dbgServer) << "A client connected but did not send data in 10 seconds. Dropping connection from" << client->peerAddress();
|
||||||
client->abort();
|
|
||||||
pendingConnections.take(client)->deleteLater();
|
pendingConnections.take(client)->deleteLater();
|
||||||
client->deleteLater();
|
client->abort();
|
||||||
});
|
});
|
||||||
timeoutTimer->start(10000);
|
timeoutTimer->start(10000);
|
||||||
clientServerMap.insert(client, transport);
|
clientServerMap.insert(client, transport);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue