mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-30 07:27:46 +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 {
|
public void flushSync() throws IOException {
|
||||||
final SocketChannel channel = this.channel;
|
final SocketChannel channel = this.channel;
|
||||||
final List<BinaryBuffer> waitingBuffers = this.waitingBuffers;
|
final List<BinaryBuffer> waitingBuffers = this.waitingBuffers;
|
||||||
|
|
||||||
if (!channel.isConnected()) throw new ClosedChannelException();
|
if (!channel.isConnected()) throw new ClosedChannelException();
|
||||||
// Fast exit if the tick buffer can be reused
|
if (waitingBuffers.isEmpty()) {
|
||||||
if (waitingBuffers.isEmpty() && tickBuffer.getPlain().writeChannel(channel))
|
tickBuffer.getPlain().writeChannel(channel);
|
||||||
return;
|
} else {
|
||||||
// Write as much as possible from the waiting list
|
// Write as much as possible from the waiting list
|
||||||
Iterator<BinaryBuffer> iterator = waitingBuffers.iterator();
|
Iterator<BinaryBuffer> iterator = waitingBuffers.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
BinaryBuffer waitingBuffer = iterator.next();
|
BinaryBuffer waitingBuffer = iterator.next();
|
||||||
if (!waitingBuffer.writeChannel(channel)) break;
|
if (!waitingBuffer.writeChannel(channel)) break;
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
PooledBuffers.add(waitingBuffer);
|
PooledBuffers.add(waitingBuffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user