Make some timeouts a bit more visible in the code. Some should be re-evaluated.

This commit is contained in:
Henrik Rydgård 2024-01-24 09:50:26 +01:00
parent 39cf5b5c30
commit 157f262cd2
2 changed files with 8 additions and 7 deletions

View File

@ -128,8 +128,10 @@ int HTTPFileLoader::SendHEAD(const Url &url, std::vector<std::string> &responseH
return -400;
}
client_.SetDataTimeout(20.0);
Connect();
double timeout = 20.0;
client_.SetDataTimeout(timeout);
Connect(10.0);
if (!connected_) {
ERROR_LOG(LOADER, "HTTP request failed, failed to connect: %s port %d (resource: '%s')", url.Host().c_str(), url.Port(), url.Resource().c_str());
latestError_ = "Could not connect (refused to connect)";
@ -186,7 +188,7 @@ size_t HTTPFileLoader::ReadAt(s64 absolutePos, size_t bytes, void *data, Flags f
return 0;
}
Connect();
Connect(10.0);
if (!connected_) {
return 0;
}
@ -258,10 +260,9 @@ size_t HTTPFileLoader::ReadAt(s64 absolutePos, size_t bytes, void *data, Flags f
return readBytes;
}
void HTTPFileLoader::Connect() {
void HTTPFileLoader::Connect(double timeout) {
if (!connected_) {
cancel_ = false;
// Latency is important here, so reduce the timeout.
connected_ = client_.Connect(3, 10.0, &cancel_);
connected_ = client_.Connect(3, timeout, &cancel_);
}
}

View File

@ -58,7 +58,7 @@ private:
void Prepare();
int SendHEAD(const Url &url, std::vector<std::string> &responseHeaders);
void Connect();
void Connect(double timeout);
void Disconnect() {
if (connected_) {