Skip to content

Commit

Permalink
Don't set the writerIndex to incorrect value when scattering reads ar…
Browse files Browse the repository at this point in the history
…e used for datagrams (netty#12076)

Motivation:

Due a bug we did set the writerIndex(...) of datagrams to an incorrect value sometimes when scattering reads are used.

Modifications:

- Remove incorrect call to writerIndex(...)
- Add comment

Result:

Correct writerIndex is used
  • Loading branch information
normanmaurer authored Feb 4, 2022
1 parent cbeb705 commit fb4a320
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.netty.channel.socket.DatagramPacket;
import io.netty.channel.unix.IovArray;
import io.netty.channel.unix.Limits;
import io.netty.channel.unix.SegmentedDatagramPacket;
import io.netty.util.internal.UnstableApi;

import java.net.Inet6Address;
Expand Down Expand Up @@ -162,6 +163,9 @@ private static InetSocketAddress newAddress(byte[] addr, int addrLen, int port,
@UnstableApi
public final class NativeDatagramPacket {

// IMPORTANT: Most of the below variables are accessed via JNI. Be aware if you change any of these you also
// need to change these in the related .c file!

// This is the actual struct iovec*
private long memoryAddress;
private int count;
Expand Down Expand Up @@ -210,7 +214,6 @@ DatagramPacket newDatagramPacket(ByteBuf buffer, InetSocketAddress recipient) th
if (recipientAddrLen != 0) {
recipient = newAddress(recipientAddr, recipientAddrLen, recipientPort, recipientScopeId, ipv4Bytes);
}
buffer.writerIndex(count);

// UDP_GRO
if (segmentSize > 0) {
Expand Down

0 comments on commit fb4a320

Please sign in to comment.