Skip to content

Commit

Permalink
Merge upstream-jdk
Browse files Browse the repository at this point in the history
  • Loading branch information
corretto-github-robot committed Jul 1, 2024
2 parents 1ac6b41 + e78c682 commit e401476
Show file tree
Hide file tree
Showing 2 changed files with 509 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -806,14 +806,19 @@ private int receive(ByteBuffer dst, boolean connected) throws IOException {
}
}

/**
* 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)
Expand Down Expand Up @@ -991,6 +996,9 @@ private int send(FileDescriptor fd, ByteBuffer src, InetSocketAddress target)
}
}

/**
* Send a datagram contained in a direct buffer.
*/
private int sendFromNativeBuffer(FileDescriptor fd, ByteBuffer bb,
InetSocketAddress target)
throws IOException
Expand All @@ -1003,9 +1011,13 @@ private int sendFromNativeBuffer(FileDescriptor fd, ByteBuffer bb,
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;
Expand Down
Loading

0 comments on commit e401476

Please sign in to comment.