mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8265309: com/sun/jndi/dns/ConfigTests/Timeout.java fails with "Address already in use" BindException
Reviewed-by: dfuchs
This commit is contained in:
parent
24bf35f862
commit
0c0ff7fb0c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -407,35 +407,30 @@ public class DnsClient {
|
||||
// Packets may only be sent to or received from this server address
|
||||
udpSocket.connect(server, port);
|
||||
int pktTimeout = (timeout * (1 << retry));
|
||||
try {
|
||||
udpSocket.send(opkt);
|
||||
udpSocket.send(opkt);
|
||||
|
||||
// timeout remaining after successive 'receive()'
|
||||
int timeoutLeft = pktTimeout;
|
||||
int cnt = 0;
|
||||
do {
|
||||
if (debug) {
|
||||
cnt++;
|
||||
dprint("Trying RECEIVE(" +
|
||||
cnt + ") retry(" + (retry + 1) +
|
||||
") for:" + xid + " sock-timeout:" +
|
||||
timeoutLeft + " ms.");
|
||||
}
|
||||
udpSocket.setSoTimeout(timeoutLeft);
|
||||
long start = System.currentTimeMillis();
|
||||
udpSocket.receive(ipkt);
|
||||
long end = System.currentTimeMillis();
|
||||
// timeout remaining after successive 'receive()'
|
||||
int timeoutLeft = pktTimeout;
|
||||
int cnt = 0;
|
||||
do {
|
||||
if (debug) {
|
||||
cnt++;
|
||||
dprint("Trying RECEIVE(" +
|
||||
cnt + ") retry(" + (retry + 1) +
|
||||
") for:" + xid + " sock-timeout:" +
|
||||
timeoutLeft + " ms.");
|
||||
}
|
||||
udpSocket.setSoTimeout(timeoutLeft);
|
||||
long start = System.currentTimeMillis();
|
||||
udpSocket.receive(ipkt);
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
byte[] data = ipkt.getData();
|
||||
if (isMatchResponse(data, xid)) {
|
||||
return data;
|
||||
}
|
||||
timeoutLeft = pktTimeout - ((int) (end - start));
|
||||
} while (timeoutLeft > minTimeout);
|
||||
|
||||
} finally {
|
||||
udpSocket.disconnect();
|
||||
}
|
||||
byte[] data = ipkt.getData();
|
||||
if (isMatchResponse(data, xid)) {
|
||||
return data;
|
||||
}
|
||||
timeoutLeft = pktTimeout - ((int) (end - start));
|
||||
} while (timeoutLeft > minTimeout);
|
||||
return null; // no matching packet received within the timeout
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ import java.time.Instant;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8200151
|
||||
* @bug 8200151 8265309
|
||||
* @summary Tests that we can set the initial UDP timeout interval and the
|
||||
* number of retries.
|
||||
* @library ../lib/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user