mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-28 22:47:41 +02:00
Do not fallback to waiting list
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
ff8dd0cdaa
commit
7a371fe616
@ -415,18 +415,18 @@ public class PlayerSocketConnection extends PlayerConnection {
|
||||
public void flushSync() throws IOException {
|
||||
final SocketChannel channel = this.channel;
|
||||
final List<BinaryBuffer> waitingBuffers = this.waitingBuffers;
|
||||
|
||||
if (!channel.isConnected()) throw new ClosedChannelException();
|
||||
// Fast exit if the tick buffer can be reused
|
||||
if (waitingBuffers.isEmpty() && tickBuffer.getPlain().writeChannel(channel))
|
||||
return;
|
||||
// Write as much as possible from the waiting list
|
||||
Iterator<BinaryBuffer> iterator = waitingBuffers.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
BinaryBuffer waitingBuffer = iterator.next();
|
||||
if (!waitingBuffer.writeChannel(channel)) break;
|
||||
iterator.remove();
|
||||
PooledBuffers.add(waitingBuffer);
|
||||
if (waitingBuffers.isEmpty()) {
|
||||
tickBuffer.getPlain().writeChannel(channel);
|
||||
} else {
|
||||
// Write as much as possible from the waiting list
|
||||
Iterator<BinaryBuffer> iterator = waitingBuffers.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
BinaryBuffer waitingBuffer = iterator.next();
|
||||
if (!waitingBuffer.writeChannel(channel)) break;
|
||||
iterator.remove();
|
||||
PooledBuffers.add(waitingBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user