improve flush() logging and impl
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
parent
4b20324418
commit
36e72019c9
|
@ -245,20 +245,26 @@ public class ServerDatagramEndPoint extends AbstractEndPoint implements ManagedS
|
||||||
@Override
|
@Override
|
||||||
public boolean flush(ByteBuffer... buffers) throws IOException
|
public boolean flush(ByteBuffer... buffers) throws IOException
|
||||||
{
|
{
|
||||||
|
boolean flushedAll = true;
|
||||||
long flushed = 0;
|
long flushed = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InetSocketAddress peer = AddressCodec.decodeInetSocketAddress(buffers[0]);
|
InetSocketAddress peer = AddressCodec.decodeInetSocketAddress(buffers[0]);
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("flushing {} buffer(s) to {}", buffers.length - 1, peer);
|
||||||
for (int i = 1; i < buffers.length; i++)
|
for (int i = 1; i < buffers.length; i++)
|
||||||
{
|
{
|
||||||
ByteBuffer buffer = buffers[i];
|
ByteBuffer buffer = buffers[i];
|
||||||
int sent = _channel.send(buffer, peer);
|
int sent = _channel.send(buffer, peer);
|
||||||
if (sent == 0)
|
if (sent == 0)
|
||||||
|
{
|
||||||
|
flushedAll = false;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
flushed += sent;
|
flushed += sent;
|
||||||
}
|
}
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("flushed {} {}", flushed, this);
|
LOG.debug("flushed {} byte(s), all flushed? {} - {}", flushed, flushedAll, this);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
@ -268,13 +274,7 @@ public class ServerDatagramEndPoint extends AbstractEndPoint implements ManagedS
|
||||||
if (flushed > 0)
|
if (flushed > 0)
|
||||||
notIdle();
|
notIdle();
|
||||||
|
|
||||||
for (ByteBuffer b : buffers)
|
return flushedAll;
|
||||||
{
|
|
||||||
if (!BufferUtil.isEmpty(b))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatagramChannel getChannel()
|
public DatagramChannel getChannel()
|
||||||
|
|
Loading…
Reference in New Issue