1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-25 05:22:06 +01:00

Fix deadline check

The pattern

if (now > deadline) break;
wait(deadline - now);

is insufficient in case "now == deadline" because the result would be
wait() being called with 0, which would mean "wait until
notified". Thus, the timeout would become infinite.
This commit is contained in:
Florian Schmaus 2016-12-19 15:13:05 +01:00
parent cfe5c2233d
commit 8511a9e67b
3 changed files with 3 additions and 3 deletions

View file

@ -185,7 +185,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
final long deadline = System.currentTimeMillis() + getPacketReplyTimeout();
while (!notified) {
final long now = System.currentTimeMillis();
if (now > deadline) break;
if (now >= deadline) break;
wait(deadline - now);
}
}

View file

@ -203,7 +203,7 @@ public final class SASLAuthentication {
final long deadline = System.currentTimeMillis() + connection.getPacketReplyTimeout();
while (!authenticationSuccessful && saslException == null) {
final long now = System.currentTimeMillis();
if (now > deadline) break;
if (now >= deadline) break;
// Wait until SASL negotiation finishes
wait(deadline - now);
}

View file

@ -36,7 +36,7 @@ public class ResultSyncPoint<R, E extends Exception> {
final long deadline = System.currentTimeMillis() + timeout;
while (result == null && exception == null) {
final long now = System.currentTimeMillis();
if (now > deadline) break;
if (now >= deadline) break;
wait(deadline - now);
}
}