mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fixes and stress improvements
This commit is contained in:
parent
d0a887f688
commit
6846a6ecad
|
@ -752,12 +752,12 @@ void thread_yield()
|
|||
#endif
|
||||
}
|
||||
|
||||
void thread_sleep(int milliseconds)
|
||||
void thread_sleep(int microseconds)
|
||||
{
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
usleep(milliseconds*1000);
|
||||
usleep(microseconds);
|
||||
#elif defined(CONF_FAMILY_WINDOWS)
|
||||
Sleep(milliseconds);
|
||||
Sleep(microseconds/1000);
|
||||
#else
|
||||
#error not implemented
|
||||
#endif
|
||||
|
@ -1538,7 +1538,7 @@ void net_init_mmsgs(MMSGS* m)
|
|||
m->msgs[i].msg_hdr.msg_iov = &m->iovecs[i];
|
||||
m->msgs[i].msg_hdr.msg_iovlen = 1;
|
||||
m->msgs[i].msg_hdr.msg_name = &m->sockaddrs[i];
|
||||
m->msgs[i].msg_hdr.msg_namelen = sizeof(&m->sockaddrs[i]);
|
||||
m->msgs[i].msg_hdr.msg_namelen = sizeof(m->sockaddrs[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -475,9 +475,9 @@ void aio_free(ASYNCIO *aio);
|
|||
Suspends the current thread for a given period.
|
||||
|
||||
Parameters:
|
||||
milliseconds - Number of milliseconds to sleep.
|
||||
microseconds - Number of microseconds to sleep.
|
||||
*/
|
||||
void thread_sleep(int milliseconds);
|
||||
void thread_sleep(int microseconds);
|
||||
|
||||
/*
|
||||
Function: thread_init
|
||||
|
|
|
@ -2960,7 +2960,7 @@ void CClient::Run()
|
|||
{
|
||||
SleepTimeInMicroSeconds = ((int64)1000000 / (int64)g_Config.m_ClRefreshRateInactive) - (Now - LastTime);
|
||||
if(SleepTimeInMicroSeconds / (int64)1000 > (int64)0)
|
||||
thread_sleep(SleepTimeInMicroSeconds / (int64)1000);
|
||||
thread_sleep(SleepTimeInMicroSeconds);
|
||||
Slept = true;
|
||||
}
|
||||
else if(g_Config.m_ClRefreshRate)
|
||||
|
@ -2990,7 +2990,7 @@ void CClient::Run()
|
|||
|
||||
if(g_Config.m_DbgHitch)
|
||||
{
|
||||
thread_sleep(g_Config.m_DbgHitch);
|
||||
thread_sleep(g_Config.m_DbgHitch*1000);
|
||||
g_Config.m_DbgHitch = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1707,9 +1707,6 @@ void CServer::PumpNetwork()
|
|||
|
||||
m_ServerBan.Update();
|
||||
m_Econ.Update();
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
m_Fifo.Update();
|
||||
#endif
|
||||
}
|
||||
|
||||
char *CServer::GetMapName()
|
||||
|
@ -1804,16 +1801,18 @@ int CServer::Run()
|
|||
|
||||
// start server
|
||||
NETADDR BindAddr;
|
||||
if(g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) == 0)
|
||||
int NetType = g_Config.m_SvIpv4Only ? NETTYPE_IPV4 : NETTYPE_ALL;
|
||||
|
||||
if(g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NetType) == 0)
|
||||
{
|
||||
// sweet!
|
||||
BindAddr.type = NETTYPE_ALL;
|
||||
BindAddr.type = NetType;
|
||||
BindAddr.port = g_Config.m_SvPort;
|
||||
}
|
||||
else
|
||||
{
|
||||
mem_zero(&BindAddr, sizeof(BindAddr));
|
||||
BindAddr.type = NETTYPE_ALL;
|
||||
BindAddr.type = NetType;
|
||||
BindAddr.port = g_Config.m_SvPort;
|
||||
}
|
||||
|
||||
|
@ -1989,6 +1988,11 @@ int CServer::Run()
|
|||
DoSnapshot();
|
||||
|
||||
UpdateClientRconCommands();
|
||||
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
if(m_CurrentGameTick%50 == 0) // Once per second is often enough
|
||||
m_Fifo.Update();
|
||||
#endif
|
||||
}
|
||||
|
||||
// master server stuff
|
||||
|
@ -2030,13 +2034,6 @@ int CServer::Run()
|
|||
int64 t = time_get();
|
||||
int x = (TickStartTime(m_CurrentGameTick+1) - t) * 1000000 / time_freq() + 1;
|
||||
|
||||
if(x > 3000)
|
||||
{
|
||||
// at least sleep 3 ms, reduce number of syscalls in stress situations
|
||||
thread_sleep(3);
|
||||
x = (TickStartTime(m_CurrentGameTick+1) - t) * 1000000 / time_freq() + 1;
|
||||
}
|
||||
|
||||
if(x > 0)
|
||||
{
|
||||
net_socket_read_wait(m_NetServer.Socket(), x);
|
||||
|
|
|
@ -132,6 +132,7 @@ MACRO_CONFIG_INT(InpIgnoredModifiers, inp_ignored_modifiers, 0, 0, 65536, CFGFLA
|
|||
|
||||
MACRO_CONFIG_STR(SvName, sv_name, 128, "unnamed server", CFGFLAG_SERVER, "Server name")
|
||||
MACRO_CONFIG_STR(Bindaddr, bindaddr, 128, "", CFGFLAG_CLIENT|CFGFLAG_SERVER|CFGFLAG_MASTER, "Address to bind the client/server to")
|
||||
MACRO_CONFIG_INT(SvIpv4Only, sv_ipv4only, 0, 0, 1, CFGFLAG_SERVER, "Whether to bind only to ipv4, otherwise bind to all available interfaces")
|
||||
MACRO_CONFIG_INT(SvPort, sv_port, 8303, 0, 0, CFGFLAG_SERVER, "Port to use for the server (Only ports 8303-8310 work in LAN server browser)")
|
||||
MACRO_CONFIG_INT(SvExternalPort, sv_external_port, 0, 0, 0, CFGFLAG_SERVER, "External port to report to the master servers")
|
||||
MACRO_CONFIG_STR(SvMap, sv_map, 128, "Kobra 4", CFGFLAG_SERVER, "Map to use on the server")
|
||||
|
|
|
@ -86,7 +86,7 @@ void CFileScore::SaveScoreThread(void *pUser)
|
|||
}
|
||||
t++;
|
||||
if (t % 50 == 0)
|
||||
thread_sleep(1);
|
||||
thread_sleep(1000);
|
||||
}
|
||||
}
|
||||
f.close();
|
||||
|
|
|
@ -82,7 +82,7 @@ void CSqlScore::OnShutdown()
|
|||
if (i % 20 == 0)
|
||||
dbg_msg("sql", "Waiting for score-threads to complete (%d left)", CSqlExecData::ms_InstanceCount);
|
||||
++i;
|
||||
thread_sleep(100);
|
||||
thread_sleep(100000);
|
||||
}
|
||||
|
||||
lock_destroy(ms_FailureFileLock);
|
||||
|
|
|
@ -534,7 +534,7 @@ int main(int argc, const char **argv) // ignore_convention
|
|||
}
|
||||
|
||||
// be nice to the CPU
|
||||
thread_sleep(1);
|
||||
thread_sleep(1000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -204,7 +204,7 @@ void Run(unsigned short Port, NETADDR Dest)
|
|||
}
|
||||
}
|
||||
|
||||
thread_sleep(1);
|
||||
thread_sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ static int Run()
|
|||
SendHeartBeats();
|
||||
}
|
||||
|
||||
thread_sleep(100);
|
||||
thread_sleep(100000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue