1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 02:14:26 +01:00

Automatic reconnect

This commit is contained in:
Ralf Ramsauer 2015-10-01 22:31:10 +02:00
parent b66c82aad8
commit 6181412d7b

View File

@ -116,6 +116,8 @@ static int doorlock_client(const std::string &hostname,
retval = -1;
}
io_service.reset();
return retval;
}
@ -169,7 +171,12 @@ int main(int argc, char** argv)
std::thread clientThread = std::thread([&] () {
// If the TCP client returns, an error has occured
// In normal operation, it never returns
doorlock_client(hostname, port);
while (run) {
doorlock_client(hostname, port);
l(LogLevel::error, "client aborted, retrying in 5 seconds");
sleep(5);
// Todo: Write message to QT frontend
}
// This will stop the Qapplication
mainWindow->hide();
@ -181,6 +188,7 @@ int main(int argc, char** argv)
// Stop the IO service
io_service.stop();
io_service.reset();
clientThread.join();