mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8338142: (dc) DatagramChannelImpl.blockingReceive can use untimed-park when no timeout set
Reviewed-by: dfuchs
This commit is contained in:
parent
6af1d6ff21
commit
58b9570544
1 changed files with 11 additions and 6 deletions
|
@ -674,7 +674,6 @@ class DatagramChannelImpl
|
|||
configureSocketNonBlocking();
|
||||
} else {
|
||||
configureSocketNonBlockingIfVirtualThread();
|
||||
nanos = Long.MAX_VALUE;
|
||||
}
|
||||
|
||||
// p.bufLength is the maximum size of the datagram that can be received
|
||||
|
@ -689,7 +688,9 @@ class DatagramChannelImpl
|
|||
SocketAddress remote = beginRead(true, false);
|
||||
boolean connected = (remote != null);
|
||||
do {
|
||||
long remainingNanos = nanos - (System.nanoTime() - startNanos);
|
||||
long remainingNanos = (nanos > 0)
|
||||
? nanos - (System.nanoTime() - startNanos)
|
||||
: 0;
|
||||
ByteBuffer dst = tryBlockingReceive(connected, bufLength, remainingNanos);
|
||||
|
||||
// if datagram received then get sender and copy to DatagramPacket
|
||||
|
@ -756,11 +757,15 @@ class DatagramChannelImpl
|
|||
Util.offerFirstTemporaryDirectBuffer(dst);
|
||||
dst = null;
|
||||
}
|
||||
long remainingNanos = nanos - (System.nanoTime() - startNanos);
|
||||
if (remainingNanos <= 0) {
|
||||
throw new SocketTimeoutException("Receive timed out");
|
||||
if (nanos > 0) {
|
||||
long remainingNanos = nanos - (System.nanoTime() - startNanos);
|
||||
if (remainingNanos <= 0) {
|
||||
throw new SocketTimeoutException("Receive timed out");
|
||||
}
|
||||
park(Net.POLLIN, remainingNanos);
|
||||
} else {
|
||||
park(Net.POLLIN);
|
||||
}
|
||||
park(Net.POLLIN, remainingNanos);
|
||||
// virtual thread needs to re-allocate temporary direct buffer after parking
|
||||
if (Thread.currentThread().isVirtual()) {
|
||||
dst = Util.getTemporaryDirectBuffer(len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue