udp-discovery-cpp icon indicating copy to clipboard operation
udp-discovery-cpp copied to clipboard

to_sleep_ms can be negative, causing SleepFor to wait for (almost) ever

Open teub opened this issue 3 years ago • 0 comments

Hello,

IsRightTime can set a negative value to to_sleep_until_next_delete_idle, causing the subsequent call to SleepFor to wait for a very long time on windows, and the process getting stuck when calling Stop(true) on the peer. Indeed, Sleep((DWORD)time_ms) casts the negative value to a very large positive value.

I don't know if IsRightTime is buggy; a possible fix would be replacing "SleepFor(to_sleep_ms);" with "SleepFor(std::max((long)0, to_sleep_ms));", or maybe do the check in the function itself.

teub avatar Nov 27 '21 20:11 teub