6781: Continue sleeping, with `cl_refresh_rate` if packet waked client up r=def- a=Jupeyy

Notice i changed the check to > 0 microseconds.. The net wait cant handle nanos, busy waiting sounds bit overkill..
Notice also, i added a comment to the issue, which might be interesting before merging

fixes #6751

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Jupeyy <jupjopjap@gmail.com>
This commit is contained in:
bors[bot] 2023-06-28 22:26:32 +00:00 committed by GitHub
commit 0e72dc331f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3343,8 +3343,15 @@ void CClient::Run()
else if(g_Config.m_ClRefreshRate)
{
SleepTimeInNanoSeconds = (std::chrono::nanoseconds(1s) / (int64_t)g_Config.m_ClRefreshRate) - (Now - LastTime);
if(SleepTimeInNanoSeconds > 0ns)
net_socket_read_wait(m_aNetClient[CONN_MAIN].m_Socket, SleepTimeInNanoSeconds);
auto SleepTimeInNanoSecondsInner = SleepTimeInNanoSeconds;
auto NowInner = Now;
while((SleepTimeInNanoSecondsInner / std::chrono::nanoseconds(1us).count()) > 0ns)
{
net_socket_read_wait(m_aNetClient[CONN_MAIN].m_Socket, SleepTimeInNanoSecondsInner);
auto NowInnerCalc = time_get_nanoseconds();
SleepTimeInNanoSecondsInner -= (NowInnerCalc - NowInner);
NowInner = NowInnerCalc;
}
Slept = true;
}
if(Slept)