mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Time out for POST requests too (hopefully fixes #5198)
This commit is contained in:
parent
73a099885b
commit
3e60cd83d0
|
@ -1744,7 +1744,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
|
|||
str_format(aUrl, sizeof(aUrl), "%s/%s", UseConfigUrl ? g_Config.m_ClMapDownloadUrl : m_aMapDownloadUrl, aEscaped);
|
||||
|
||||
m_pMapdownloadTask = HttpGetFile(aUrl, Storage(), m_aMapdownloadFilenameTemp, IStorage::TYPE_SAVE);
|
||||
m_pMapdownloadTask->Timeout(CTimeout{g_Config.m_ClMapDownloadConnectTimeoutMs, g_Config.m_ClMapDownloadLowSpeedLimit, g_Config.m_ClMapDownloadLowSpeedTime});
|
||||
m_pMapdownloadTask->Timeout(CTimeout{g_Config.m_ClMapDownloadConnectTimeoutMs, 0, g_Config.m_ClMapDownloadLowSpeedLimit, g_Config.m_ClMapDownloadLowSpeedTime});
|
||||
Engine()->AddJob(m_pMapdownloadTask);
|
||||
}
|
||||
else
|
||||
|
@ -4644,7 +4644,7 @@ void CClient::RequestDDNetInfo()
|
|||
|
||||
// Use ipv4 so we can know the ingame ip addresses of players before they join game servers
|
||||
m_pDDNetInfoTask = HttpGetFile(aUrl, Storage(), m_aDDNetInfoTmp, IStorage::TYPE_SAVE);
|
||||
m_pDDNetInfoTask->Timeout(CTimeout{10000, 500, 10});
|
||||
m_pDDNetInfoTask->Timeout(CTimeout{10000, 0, 500, 10});
|
||||
m_pDDNetInfoTask->IpResolve(IPRESOLVE::V4);
|
||||
Engine()->AddJob(m_pDDNetInfoTask);
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ void CChooseMaster::CJob::Run()
|
|||
//
|
||||
// 10 seconds connection timeout, lower than 8KB/s for 10 seconds to
|
||||
// fail.
|
||||
CTimeout Timeout{10000, 8000, 10};
|
||||
CTimeout Timeout{10000, 0, 8000, 10};
|
||||
int aTimeMs[MAX_URLS];
|
||||
for(int i = 0; i < m_pData->m_NumUrls; i++)
|
||||
{
|
||||
|
@ -339,7 +339,7 @@ void CServerBrowserHttp::Update()
|
|||
}
|
||||
m_pGetServers = HttpGet(pBestUrl);
|
||||
// 10 seconds connection timeout, lower than 8KB/s for 10 seconds to fail.
|
||||
m_pGetServers->Timeout(CTimeout{10000, 8000, 10});
|
||||
m_pGetServers->Timeout(CTimeout{10000, 0, 8000, 10});
|
||||
m_pEngine->AddJob(m_pGetServers);
|
||||
m_State = STATE_REFRESHING;
|
||||
}
|
||||
|
|
|
@ -197,6 +197,7 @@ int CHttpRequest::RunImpl(CURL *pUser)
|
|||
curl_easy_setopt(pHandle, CURLOPT_ERRORBUFFER, aErr);
|
||||
|
||||
curl_easy_setopt(pHandle, CURLOPT_CONNECTTIMEOUT_MS, m_Timeout.ConnectTimeoutMs);
|
||||
curl_easy_setopt(pHandle, CURLOPT_TIMEOUT_MS, m_Timeout.TimeoutMs);
|
||||
curl_easy_setopt(pHandle, CURLOPT_LOW_SPEED_LIMIT, m_Timeout.LowSpeedLimit);
|
||||
curl_easy_setopt(pHandle, CURLOPT_LOW_SPEED_TIME, m_Timeout.LowSpeedTime);
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ enum class IPRESOLVE
|
|||
struct CTimeout
|
||||
{
|
||||
long ConnectTimeoutMs;
|
||||
long TimeoutMs;
|
||||
long LowSpeedLimit;
|
||||
long LowSpeedTime;
|
||||
};
|
||||
|
@ -53,7 +54,7 @@ class CHttpRequest : public IJob
|
|||
unsigned char *m_pBody = nullptr;
|
||||
size_t m_BodyLength = 0;
|
||||
|
||||
CTimeout m_Timeout = CTimeout{0, 0, 0};
|
||||
CTimeout m_Timeout = CTimeout{0, 0, 0, 0};
|
||||
REQUEST m_Type = REQUEST::GET;
|
||||
|
||||
bool m_WriteToFile = false;
|
||||
|
@ -168,7 +169,7 @@ inline std::unique_ptr<CHttpRequest> HttpGetFile(const char *pUrl, IStorage *pSt
|
|||
{
|
||||
std::unique_ptr<CHttpRequest> pResult = HttpGet(pUrl);
|
||||
pResult->WriteToFile(pStorage, pOutputFile, StorageType);
|
||||
pResult->Timeout(CTimeout{4000, 500, 5});
|
||||
pResult->Timeout(CTimeout{4000, 0, 500, 5});
|
||||
return pResult;
|
||||
}
|
||||
|
||||
|
@ -176,6 +177,7 @@ inline std::unique_ptr<CHttpRequest> HttpPost(const char *pUrl, const unsigned c
|
|||
{
|
||||
std::unique_ptr<CHttpRequest> pResult = std::unique_ptr<CHttpRequest>(new CHttpRequest(pUrl));
|
||||
pResult->Post(pData, DataLength);
|
||||
pResult->Timeout(CTimeout{4000, 15000, 500, 5});
|
||||
return pResult;
|
||||
}
|
||||
|
||||
|
@ -183,6 +185,7 @@ inline std::unique_ptr<CHttpRequest> HttpPostJson(const char *pUrl, const char *
|
|||
{
|
||||
std::unique_ptr<CHttpRequest> pResult = std::unique_ptr<CHttpRequest>(new CHttpRequest(pUrl));
|
||||
pResult->PostJson(pJson);
|
||||
pResult->Timeout(CTimeout{4000, 15000, 500, 5});
|
||||
return pResult;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ CSkins::CGetPngFile::CGetPngFile(CSkins *pSkins, const char *pUrl, IStorage *pSt
|
|||
m_pSkins(pSkins)
|
||||
{
|
||||
WriteToFile(pStorage, pDest, IStorage::TYPE_SAVE);
|
||||
Timeout(CTimeout{0, 0, 0});
|
||||
Timeout(CTimeout{0, 0, 0, 0});
|
||||
LogProgress(HTTPLOG::NONE);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue