From 4fc3551822a57a3b26d0c4540e205f9b340f9899 Mon Sep 17 00:00:00 2001 From: Alex Borisov Date: Sun, 4 Dec 2011 22:38:58 +0200 Subject: FIX reconnection bug & server entry parser --- client/UpdatedConfig.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'client/UpdatedConfig.cpp') diff --git a/client/UpdatedConfig.cpp b/client/UpdatedConfig.cpp index 860042d..9ebae8a 100644 --- a/client/UpdatedConfig.cpp +++ b/client/UpdatedConfig.cpp @@ -35,7 +35,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 +68,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; } -- cgit v1.2.3 From 66732a17595882c9921579f8f22f0e6f307050f4 Mon Sep 17 00:00:00 2001 From: Alex Borisov Date: Mon, 5 Dec 2011 00:14:31 +0200 Subject: FIX inf loop when empty pkts recieved --- client/UpdatedConfig.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'client/UpdatedConfig.cpp') diff --git a/client/UpdatedConfig.cpp b/client/UpdatedConfig.cpp index 9ebae8a..739210d 100644 --- a/client/UpdatedConfig.cpp +++ b/client/UpdatedConfig.cpp @@ -159,9 +159,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); -- cgit v1.2.3 From 9974bde9106a1d7e05fbe12266d8bbfe00436a62 Mon Sep 17 00:00:00 2001 From: Alex Borisov Date: Mon, 5 Dec 2011 01:13:18 +0200 Subject: FIX error when choosing active serv on reconnect --- client/UpdatedConfig.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'client/UpdatedConfig.cpp') diff --git a/client/UpdatedConfig.cpp b/client/UpdatedConfig.cpp index 739210d..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() @@ -174,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(); -- cgit v1.2.3