mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-21 19:42:05 +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:
parent
cfe5c2233d
commit
8511a9e67b
3 changed files with 3 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue