mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
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:
parent
1674a95b2d
commit
bcdb3e0247
|
@ -186,8 +186,8 @@ int CRequest::ProgressCallback(void *pUser, double DlTotal, double DlCurr, doubl
|
||||||
return pTask->m_Abort ? -1 : 0;
|
return pTask->m_Abort ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHead::CHead(const char *pUrl, CTimeout Timeout) :
|
CHead::CHead(const char *pUrl, CTimeout Timeout, bool LogProgress) :
|
||||||
CRequest(pUrl, Timeout)
|
CRequest(pUrl, Timeout, LogProgress)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,8 +202,8 @@ bool CHead::AfterInit(void *pCurl)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGet::CGet(const char *pUrl, CTimeout Timeout) :
|
CGet::CGet(const char *pUrl, CTimeout Timeout, bool LogProgress) :
|
||||||
CRequest(pUrl, Timeout),
|
CRequest(pUrl, Timeout, LogProgress),
|
||||||
m_BufferSize(0),
|
m_BufferSize(0),
|
||||||
m_BufferLength(0),
|
m_BufferLength(0),
|
||||||
m_pBuffer(NULL)
|
m_pBuffer(NULL)
|
||||||
|
|
|
@ -72,7 +72,7 @@ class CHead : public CRequest
|
||||||
virtual bool AfterInit(void *pCurl);
|
virtual bool AfterInit(void *pCurl);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CHead(const char *pUrl, CTimeout Timeout);
|
CHead(const char *pUrl, CTimeout Timeout, bool LogProgress = true);
|
||||||
~CHead();
|
~CHead();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ class CGet : public CRequest
|
||||||
unsigned char *m_pBuffer;
|
unsigned char *m_pBuffer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CGet(const char *pUrl, CTimeout Timeout);
|
CGet(const char *pUrl, CTimeout Timeout, bool LogProgress = true);
|
||||||
~CGet();
|
~CGet();
|
||||||
|
|
||||||
size_t ResultSize() const
|
size_t ResultSize() const
|
||||||
|
|
|
@ -137,14 +137,14 @@ void CChooseMaster::CJob::Run()
|
||||||
{
|
{
|
||||||
aTimeMs[i] = -1;
|
aTimeMs[i] = -1;
|
||||||
const char *pUrl = m_pData->m_aaUrls[aRandomized[i]];
|
const char *pUrl = m_pData->m_aaUrls[aRandomized[i]];
|
||||||
CHead Head(pUrl, Timeout);
|
CHead Head(pUrl, Timeout, false);
|
||||||
IEngine::RunJobBlocking(&Head);
|
IEngine::RunJobBlocking(&Head);
|
||||||
if(Head.State() != HTTP_DONE)
|
if(Head.State() != HTTP_DONE)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int64 StartTime = time_get();
|
int64 StartTime = time_get();
|
||||||
CGet Get(pUrl, Timeout);
|
CGet Get(pUrl, Timeout, false);
|
||||||
IEngine::RunJobBlocking(&Get);
|
IEngine::RunJobBlocking(&Get);
|
||||||
int Time = (time_get() - StartTime) * 1000 / time_freq();
|
int Time = (time_get() - StartTime) * 1000 / time_freq();
|
||||||
if(Get.State() != HTTP_DONE)
|
if(Get.State() != HTTP_DONE)
|
||||||
|
|
Loading…
Reference in a new issue