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:
parent
ed49749897
commit
add0c8b605
|
@ -107,13 +107,12 @@ public class ServerDatagramEndPoint extends IdleTimeout implements EndPoint, Man
|
||||||
@Override
|
@Override
|
||||||
public int fill(ByteBuffer buffer) throws IOException
|
public int fill(ByteBuffer buffer) throws IOException
|
||||||
{
|
{
|
||||||
BufferUtil.flipToFill(buffer);
|
|
||||||
int headerPosition = buffer.position();
|
int headerPosition = buffer.position();
|
||||||
buffer.position(buffer.position() + ENCODED_ADDRESS_LENGTH);
|
buffer.position(buffer.position() + ENCODED_ADDRESS_LENGTH);
|
||||||
InetSocketAddress peer = (InetSocketAddress)channel.receive(buffer);
|
InetSocketAddress peer = (InetSocketAddress)channel.receive(buffer);
|
||||||
if (peer == null)
|
if (peer == null)
|
||||||
{
|
{
|
||||||
buffer.position(0);
|
buffer.position(headerPosition);
|
||||||
buffer.flip();
|
buffer.flip();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue