Add write water mark, reduce debug prints, update netty to latest

This commit is contained in:
themode 2021-02-17 05:03:31 +01:00
parent 16ad864c09
commit 590e6cb939
4 changed files with 14 additions and 8 deletions

View File

@ -106,10 +106,10 @@ dependencies {
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.6.2')
// Netty
api 'io.netty:netty-handler:4.1.58.Final'
api 'io.netty:netty-codec:4.1.58.Final'
api 'io.netty:netty-transport-native-epoll:4.1.58.Final:linux-x86_64'
api 'io.netty:netty-transport-native-kqueue:4.1.58.Final:osx-x86_64'
api 'io.netty:netty-handler:4.1.59.Final'
api 'io.netty:netty-codec:4.1.59.Final'
api 'io.netty:netty-transport-native-epoll:4.1.59.Final:linux-x86_64'
api 'io.netty:netty-transport-native-kqueue:4.1.59.Final:osx-x86_64'
api 'io.netty.incubator:netty-incubator-transport-native-io_uring:0.0.3.Final:linux-x86_64'
// https://mvnrepository.com/artifact/org.apache.commons/commons-text

View File

@ -36,6 +36,8 @@ import java.util.concurrent.ScheduledExecutorService;
public final class NettyServer {
public static final Logger LOGGER = LoggerFactory.getLogger(NettyServer.class);
private static final WriteBufferWaterMark SERVER_WRITE_MARK = new WriteBufferWaterMark(1 << 20,
1 << 21);
private static final long DEFAULT_COMPRESSED_CHANNEL_WRITE_LIMIT = 600_000L;
private static final long DEFAULT_COMPRESSED_CHANNEL_READ_LIMIT = 100_000L;
@ -154,6 +156,7 @@ public final class NettyServer {
bootstrap = new ServerBootstrap()
.group(boss, worker)
.childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, SERVER_WRITE_MARK)
.channel(channel);

View File

@ -72,8 +72,11 @@ public class ClientChannel extends SimpleChannelInboundHandler<InboundPacket> {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
if (!ctx.channel().isActive()) {
return;
}
if (MinecraftServer.shouldProcessNettyErrors()) {
LOGGER.info(cause.getMessage());
MinecraftServer.getExceptionManager().handleException(cause);
}
ctx.close();

View File

@ -112,7 +112,7 @@ public class NettyPlayerConnection extends PlayerConnection {
*/
@Override
public void sendPacket(@NotNull ServerPacket serverPacket) {
if (!isOnline())
if (!channel.isActive())
return;
if (shouldSendPacket(serverPacket)) {
@ -152,7 +152,7 @@ public class NettyPlayerConnection extends PlayerConnection {
if (MinecraftServer.shouldProcessNettyErrors()) {
return channelFuture.addListener(future -> {
if (!future.isSuccess()) {
if (!future.isSuccess() && channel.isActive()) {
MinecraftServer.getExceptionManager().handleException(future.cause());
}
});
@ -167,7 +167,7 @@ public class NettyPlayerConnection extends PlayerConnection {
if (MinecraftServer.shouldProcessNettyErrors()) {
return channelFuture.addListener(future -> {
if (!future.isSuccess()) {
if (!future.isSuccess() && channel.isActive()) {
MinecraftServer.getExceptionManager().handleException(future.cause());
}
});