fill now expects a fillable buffer + resets the buffer's position when nothing is read

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2021-03-16 10:16:04 +01:00 committed by Simone Bordet
parent ed49749897
commit add0c8b605
1 changed files with 1 additions and 2 deletions

View File

@ -107,13 +107,12 @@ public class ServerDatagramEndPoint extends IdleTimeout implements EndPoint, Man
@Override
public int fill(ByteBuffer buffer) throws IOException
{
BufferUtil.flipToFill(buffer);
int headerPosition = buffer.position();
buffer.position(buffer.position() + ENCODED_ADDRESS_LENGTH);
InetSocketAddress peer = (InetSocketAddress)channel.receive(buffer);
if (peer == null)
{
buffer.position(0);
buffer.position(headerPosition);
buffer.flip();
return 0;
}