Fix potential invalid select timeouts.
[jagi.git] / src / jagi / event / Driver.java
index 4d23c76..59f54a3 100644 (file)
@@ -112,7 +112,7 @@ public class Driver {
                            return;
                        }
                        if(first != null)
-                           timeout = (long)Math.ceil((first - now) * 1000);
+                           timeout = Math.max((long)Math.ceil((first - now) * 1000), 0);
                    }
                    poll.selectedKeys().clear();
                    try {