record.notifyCompleteAndRecycle();
written += EMPTY_RECORD_SPACE_VALUE;
continue;
}
final WriteResult firstResult = record.getCurrentResult();
final Buffer firstMessage = record.getMessage();
final long firstMessageRemaining =
record.getInitialMessageSize() - firstResult.getWrittenSize();
if (remainder >= firstMessageRemaining) {
remainder -= firstMessageRemaining;
queue.removeFirst();
firstResult.setWrittenSize(record.getInitialMessageSize());
firstMessage.position(firstMessage.limit());
((TCPNIOConnection) connection).onWrite(firstMessage, firstMessageRemaining);
record.notifyCompleteAndRecycle();
} else {
firstMessage.position(firstMessage.position() + remainder);
firstResult.setWrittenSize(
firstResult.getWrittenSize() + remainder);
((TCPNIOConnection) connection).onWrite(firstMessage, remainder);
return written;
}
}