Reduce spamminess of http server browser

As reported by fokkonaut on Discord. Not sure if we lose relevant
information.

Previously:

[2021-05-28 12:08:54][http]: http https://master2.ddnet.tw/ddnet/15/servers.json
[2021-05-28 12:08:55][http]: task done https://master2.ddnet.tw/ddnet/15/servers.json
[2021-05-28 12:08:55][http]: http https://master2.ddnet.tw/ddnet/15/servers.json
[2021-05-28 12:08:57][http]: task done https://master2.ddnet.tw/ddnet/15/servers.json
[2021-05-28 12:08:57][serverbrowse_http]: found master, url='https://master2.ddnet.tw/ddnet/15/servers.json' time=2437ms
[2021-05-28 12:08:57][http]: http https://master4.ddnet.tw/ddnet/15/servers.json
[2021-05-28 12:08:57][http]: task failed. libcurl error: Could not resolve host: master4.ddnet.tw
[2021-05-28 12:08:57][http]: http https://master3.ddnet.tw/ddnet/15/servers.json
[2021-05-28 12:08:57][http]: task failed. libcurl error: Could not resolve host: master3.ddnet.tw
[2021-05-28 12:08:57][http]: http https://master1.ddnet.tw/ddnet/15/servers.json
[2021-05-28 12:08:57][http]: task done https://master1.ddnet.tw/ddnet/15/servers.json
[2021-05-28 12:08:57][http]: http https://master1.ddnet.tw/ddnet/15/servers.json
[2021-05-28 12:08:58][http]: task done https://master1.ddnet.tw/ddnet/15/servers.json
[2021-05-28 12:08:58][serverbrowse_http]: found master, url='https://master1.ddnet.tw/ddnet/15/servers.json' time=201ms
[2021-05-28 12:08:58][serverbrowse_http]: determined best master, url='https://master1.ddnet.tw/ddnet/15/servers.json' time=201ms
[2021-05-28 12:08:58][http]: http https://master1.ddnet.tw/ddnet/15/servers.json
[2021-05-28 12:08:58][http]: task done https://master1.ddnet.tw/ddnet/15/servers.json

Now:

[2021-05-28 12:29:58][http]: http https://master1.ddnet.tw/ddnet/15/servers.json
[2021-05-28 12:29:59][http]: task done https://master1.ddnet.tw/ddnet/15/servers.json
[2021-05-28 12:30:00][serverbrowse_http]: found master, url='https://master2.ddnet.tw/ddnet/15/servers.json' time=799ms
[2021-05-28 12:30:00][serverbrowse_http]: found master, url='https://master1.ddnet.tw/ddnet/15/servers.json' time=43ms
[2021-05-28 12:30:00][serverbrowse_http]: determined best master, url='https://master1.ddnet.tw/ddnet/15/servers.json' time=43ms
This commit is contained in:
def 2021-05-28 12:18:53 +02:00
parent 1674a95b2d
commit bcdb3e0247
3 changed files with 8 additions and 8 deletions

View file

@ -186,8 +186,8 @@ int CRequest::ProgressCallback(void *pUser, double DlTotal, double DlCurr, doubl
return pTask->m_Abort ? -1 : 0;
}
CHead::CHead(const char *pUrl, CTimeout Timeout) :
CRequest(pUrl, Timeout)
CHead::CHead(const char *pUrl, CTimeout Timeout, bool LogProgress) :
CRequest(pUrl, Timeout, LogProgress)
{
}
@ -202,8 +202,8 @@ bool CHead::AfterInit(void *pCurl)
return true;
}
CGet::CGet(const char *pUrl, CTimeout Timeout) :
CRequest(pUrl, Timeout),
CGet::CGet(const char *pUrl, CTimeout Timeout, bool LogProgress) :
CRequest(pUrl, Timeout, LogProgress),
m_BufferSize(0),
m_BufferLength(0),
m_pBuffer(NULL)

View file

@ -72,7 +72,7 @@ class CHead : public CRequest
virtual bool AfterInit(void *pCurl);
public:
CHead(const char *pUrl, CTimeout Timeout);
CHead(const char *pUrl, CTimeout Timeout, bool LogProgress = true);
~CHead();
};
@ -85,7 +85,7 @@ class CGet : public CRequest
unsigned char *m_pBuffer;
public:
CGet(const char *pUrl, CTimeout Timeout);
CGet(const char *pUrl, CTimeout Timeout, bool LogProgress = true);
~CGet();
size_t ResultSize() const

View file

@ -137,14 +137,14 @@ void CChooseMaster::CJob::Run()
{
aTimeMs[i] = -1;
const char *pUrl = m_pData->m_aaUrls[aRandomized[i]];
CHead Head(pUrl, Timeout);
CHead Head(pUrl, Timeout, false);
IEngine::RunJobBlocking(&Head);
if(Head.State() != HTTP_DONE)
{
continue;
}
int64 StartTime = time_get();
CGet Get(pUrl, Timeout);
CGet Get(pUrl, Timeout, false);
IEngine::RunJobBlocking(&Get);
int Time = (time_get() - StartTime) * 1000 / time_freq();
if(Get.State() != HTTP_DONE)