summaryrefslogtreecommitdiff
path: root/client/UpdatedConfig.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client/UpdatedConfig.cpp')
-rw-r--r--client/UpdatedConfig.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/client/UpdatedConfig.cpp b/client/UpdatedConfig.cpp
index 860042d..d5b4177 100644
--- a/client/UpdatedConfig.cpp
+++ b/client/UpdatedConfig.cpp
@@ -19,7 +19,8 @@ string UpdatedConfig::GetServerAddr()
Logger::Error("No valid server records present!\n");
return string("");
}
- return servers[activeSrvIndex].host;
+ string ret = servers[activeSrvIndex].host;
+ return ret;
}
UpdatedConfig::UpdatedConfig()
@@ -35,7 +36,7 @@ UpdatedConfig::UpdatedConfig()
return;
}
- client = new SslClient(QString::fromStdString(servers[0].host));
+ client = new SslClient(QString::fromLocal8Bit(servers[0].host.c_str()));
connect(client, SIGNAL(ReplyRecieved(SslClient::RequestType&, QByteArray&)),
this, SLOT(gotServerReply(SslClient::RequestType&, QByteArray&)));
connect(client, SIGNAL(ConnectionError()),
@@ -68,6 +69,11 @@ void UpdatedConfig::update()
{
activeSrvIndex = 0;
}
+ ServerEntry current = servers[activeSrvIndex];
+ client->SetServerAddr(QString::fromLocal8Bit(current.host.c_str()));
+ configUpdateTimer->stop();
+ configUpdateTimer->setInterval(current.retryTimeout * 1000);
+ configUpdateTimer->start();
}
retryFailed = false;
}
@@ -154,9 +160,10 @@ void UpdatedConfig::gotServerReply(SslClient::RequestType &type, QByteArray &con
Logger::Warn("Unknown reply type: %x\n", type);
break;
}
- updateStatus |= (1 << type);
end:
+ updateStatus |= (1 << type);
+
if (updateStatus != UPDATED_STATE_FULL)
{
Logger::Trace("Still need to update other config parts. Update status: %x\n", updateStatus);
@@ -168,10 +175,10 @@ end:
client->Disconnect();
configValid = true;
- /* reset retry params and setup timer to fire on next planned update */
+ // reset retry params and setup timer to fire on next planned update
+ // but leave activeSrvIndex as it is, so we will reconnect to the same working serv next time
time = 0;
updateStatus = 0;
- activeSrvIndex = 0;
retryFailed = false;
configUpdateTimer->stop();