From 68413574aab1fb4115b906d9a531fa5ac2cd7405 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 25 Oct 2019 11:14:06 -0700 Subject: [PATCH] Guard against busy spinning in HashedWheelTimer when using windows and a tickDuration of 1 (#9714) Motivation: We do not correct guard against the gact that when applying our workaround for windows we may end up with a 0 sleep period. In this case we should just sleep for 1 ms. Modifications: Guard agains the case when our calculation will produce 0 as sleep time on windows Result: Fixes https://github.com/netty/netty/issues/9710. --- common/src/main/java/io/netty/util/HashedWheelTimer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/src/main/java/io/netty/util/HashedWheelTimer.java b/common/src/main/java/io/netty/util/HashedWheelTimer.java index 4b2f5459d4..395253be42 100644 --- a/common/src/main/java/io/netty/util/HashedWheelTimer.java +++ b/common/src/main/java/io/netty/util/HashedWheelTimer.java @@ -563,6 +563,9 @@ public class HashedWheelTimer implements Timer { // See https://github.com/netty/netty/issues/356 if (PlatformDependent.isWindows()) { sleepTimeMs = sleepTimeMs / 10 * 10; + if (sleepTimeMs == 0) { + sleepTimeMs = 1; + } } try {