mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8333849: (dc) DatagramChannel send/receive fails with UOE if buffer backed by memory segment allocated from shared arena
Reviewed-by: dfuchs
This commit is contained in:
parent
ec1664e8c9
commit
e7dc76b577
2 changed files with 509 additions and 3 deletions
|
@ -806,14 +806,19 @@ class DatagramChannelImpl
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives a datagram into a direct buffer.
|
||||
*/
|
||||
private int receiveIntoNativeBuffer(ByteBuffer bb, int rem, int pos,
|
||||
boolean connected)
|
||||
throws IOException
|
||||
{
|
||||
NIO_ACCESS.acquireSession(bb);
|
||||
try {
|
||||
long bufAddress = NIO_ACCESS.getBufferAddress(bb);
|
||||
int n = receive0(fd,
|
||||
((DirectBuffer)bb).address() + pos, rem,
|
||||
bufAddress + pos,
|
||||
rem,
|
||||
sourceSockAddr.address(),
|
||||
connected);
|
||||
if (n > 0)
|
||||
|
@ -991,6 +996,9 @@ class DatagramChannelImpl
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a datagram contained in a direct buffer.
|
||||
*/
|
||||
private int sendFromNativeBuffer(FileDescriptor fd, ByteBuffer bb,
|
||||
InetSocketAddress target)
|
||||
throws IOException
|
||||
|
@ -1003,9 +1011,13 @@ class DatagramChannelImpl
|
|||
int written;
|
||||
NIO_ACCESS.acquireSession(bb);
|
||||
try {
|
||||
long bufAddress = NIO_ACCESS.getBufferAddress(bb);
|
||||
int addressLen = targetSocketAddress(target);
|
||||
written = send0(fd, ((DirectBuffer)bb).address() + pos, rem,
|
||||
targetSockAddr.address(), addressLen);
|
||||
written = send0(fd,
|
||||
bufAddress + pos,
|
||||
rem,
|
||||
targetSockAddr.address(),
|
||||
addressLen);
|
||||
} catch (PortUnreachableException pue) {
|
||||
if (isConnected())
|
||||
throw pue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue