mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-23 08:31:26 +01:00
Do not write empty buffer
This commit is contained in:
parent
1b162c1139
commit
1ceffd8540
@ -71,12 +71,15 @@ public class NettyPlayerConnection extends PlayerConnection {
|
||||
@Override
|
||||
public void update() {
|
||||
// Flush
|
||||
final int bufferSize = tickBuffer.writerIndex();
|
||||
if (bufferSize > 0) {
|
||||
this.channel.eventLoop().submit(() -> {
|
||||
if (channel.isActive()) {
|
||||
writeWaitingPackets();
|
||||
this.channel.flush();
|
||||
channel.flush();
|
||||
}
|
||||
});
|
||||
}
|
||||
// Network stats
|
||||
super.update();
|
||||
}
|
||||
@ -208,6 +211,11 @@ public class NettyPlayerConnection extends PlayerConnection {
|
||||
private void writeWaitingPackets() {
|
||||
synchronized (tickBuffer) {
|
||||
final ByteBuf copy = tickBuffer.copy();
|
||||
if (copy.writerIndex() == 0) {
|
||||
// Nothing to write
|
||||
copy.release();
|
||||
return;
|
||||
}
|
||||
|
||||
ChannelFuture channelFuture = channel.write(new FramedPacket(copy));
|
||||
channelFuture.addListener(future -> copy.release());
|
||||
|
Loading…
Reference in New Issue
Block a user