|
@ -36,9 +36,14 @@ Config Settings::getSettings() { |
|
|
if (server.trimmed().isEmpty()) { |
|
|
if (server.trimmed().isEmpty()) { |
|
|
server = Settings::getRandomServer(); |
|
|
server = Settings::getRandomServer(); |
|
|
|
|
|
|
|
|
|
|
|
QString response = ""; |
|
|
// make sure existing server in conf is alive, otherwise choose random one
|
|
|
// make sure existing server in conf is alive, otherwise choose random one
|
|
|
char* resp = litelib_initialize_existing(false, server.toStdString().c_str()); |
|
|
try { |
|
|
QString response = litelib_process_response(resp); |
|
|
char* resp = litelib_initialize_existing(false, server.toStdString().c_str()); |
|
|
|
|
|
response = litelib_process_response(resp); |
|
|
|
|
|
} catch (const std::exception& e) { |
|
|
|
|
|
qDebug() << __func__ << ": caught an exception, ignoring: " << e.what(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (response.toUpper().trimmed() != "OK") { |
|
|
if (response.toUpper().trimmed() != "OK") { |
|
|
qDebug() << "Lite server in conf " << server << " is down, getting a random one"; |
|
|
qDebug() << "Lite server in conf " << server << " is down, getting a random one"; |
|
@ -310,14 +315,14 @@ QString Settings::getRandomServer() { |
|
|
// We try every server,in order, starting from a random place in the list
|
|
|
// We try every server,in order, starting from a random place in the list
|
|
|
while (tries < servers.size() ) { |
|
|
while (tries < servers.size() ) { |
|
|
qDebug() << "Checking if lite server " << server << " is a alive, try=" << tries; |
|
|
qDebug() << "Checking if lite server " << server << " is a alive, try=" << tries; |
|
|
char* resp = litelib_initialize_existing(false, server.toStdString().c_str()); |
|
|
|
|
|
|
|
|
|
|
|
QString response = ""; |
|
|
QString response = ""; |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
|
|
|
char* resp = litelib_initialize_existing(false, server.toStdString().c_str()); |
|
|
response = litelib_process_response(resp); |
|
|
response = litelib_process_response(resp); |
|
|
} catch (const std::exception& e) { |
|
|
} catch (const std::exception& e) { |
|
|
qDebug() << __func__ << ": litelib_process_response threw an exception, ignoring: " << e.what(); |
|
|
qDebug() << __func__ << ": caught an exception, ignoring: " << e.what(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// if we see a valid connection, return this server
|
|
|
// if we see a valid connection, return this server
|
|
|