mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-17 01:12:39 +01:00
This commit is contained in:
@@ -611,8 +611,6 @@ void ClientNetworkContentSocketHandler::OnReceiveData(std::unique_ptr<char[]> da
|
||||
return;
|
||||
}
|
||||
|
||||
this->lastActivity = std::chrono::steady_clock::now();
|
||||
|
||||
if (this->http_response_index == -1) {
|
||||
if (data != nullptr) {
|
||||
/* Append the rest of the response. */
|
||||
@@ -799,7 +797,6 @@ void ClientNetworkContentSocketHandler::Connect()
|
||||
*/
|
||||
NetworkRecvStatus ClientNetworkContentSocketHandler::CloseConnection(bool)
|
||||
{
|
||||
this->isCancelled = true;
|
||||
NetworkContentSocketHandler::CloseConnection();
|
||||
|
||||
if (this->sock == INVALID_SOCKET) return NETWORK_RECV_STATUS_OKAY;
|
||||
@@ -810,6 +807,15 @@ NetworkRecvStatus ClientNetworkContentSocketHandler::CloseConnection(bool)
|
||||
return NETWORK_RECV_STATUS_OKAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the current download.
|
||||
*/
|
||||
void ClientNetworkContentSocketHandler::Cancel(void)
|
||||
{
|
||||
this->isCancelled = true;
|
||||
this->CloseConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether we received/can send some data from/to the content server and
|
||||
* when that's the case handle it appropriately
|
||||
@@ -818,6 +824,7 @@ void ClientNetworkContentSocketHandler::SendReceive()
|
||||
{
|
||||
if (this->sock == INVALID_SOCKET || this->isConnecting) return;
|
||||
|
||||
/* Close the connection to the content server after inactivity; there can still be downloads pending via HTTP. */
|
||||
if (std::chrono::steady_clock::now() > this->lastActivity + IDLE_TIMEOUT) {
|
||||
this->CloseConnection();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user