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.
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.