Skip to content

Commit 3dd5ee4

Browse files
committed
Fix - Retries are not done when connection is destructed
1 parent e316699 commit 3dd5ee4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

libsrc/flatbufserver/FlatBufferConnection.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,21 @@ FlatBufferConnection::FlatBufferConnection(const QString& origin, const QHostAdd
3030
// init connect
3131
connectToRemoteHost();
3232

33-
// start the connection timer
3433
_timer.setInterval(5000);
35-
3634
connect(&_timer, &QTimer::timeout, this, &FlatBufferConnection::connectToRemoteHost);
35+
36+
//Trigger the retry timer when connection dropped
37+
connect(this, &FlatBufferConnection::isDisconnected, &_timer, static_cast<void (QTimer::*)()>(&QTimer::start));
3738
_timer.start();
3839
}
3940

4041
FlatBufferConnection::~FlatBufferConnection()
4142
{
4243
_timer.stop();
44+
45+
//Stop retrying on disconnect
46+
disconnect(this, &FlatBufferConnection::isDisconnected, &_timer, static_cast<void (QTimer::*)()>(&QTimer::start));
47+
4348
Debug(_log, "Closing connection with host: %s, port [%u]", QSTRING_CSTR(_host.toString()), _port);
4449
_socket.close();
4550
}
@@ -58,7 +63,6 @@ void FlatBufferConnection::onDisconnected()
5863
_isRegistered = false,
5964
Info(_log, "Disconnected from target host: %s, port [%u]", QSTRING_CSTR(_host.toString()), _port);
6065
emit isDisconnected();
61-
_timer.start();
6266
}
6367

6468

@@ -225,8 +229,8 @@ bool FlatBufferConnection::parseReply(const hyperionnet::Reply *reply)
225229
}
226230
else
227231
{
228-
_timer.stop();
229232
_isRegistered = true;
233+
_timer.stop();
230234
Debug(_log,"Client \"%s\" registered successfully with target host: %s, port [%u]", QSTRING_CSTR(_origin), QSTRING_CSTR(_host.toString()), _port);
231235
emit isReadyToSend();
232236
}

0 commit comments

Comments
 (0)