A few internal comments

This commit is contained in:
Felix Cravic 2020-11-26 01:38:08 +01:00
parent ae845e38ab
commit 79a5f99358
2 changed files with 9 additions and 6 deletions

View File

@ -32,11 +32,11 @@ import java.util.concurrent.ScheduledExecutorService;
public final class NettyServer { public final class NettyServer {
public static final Logger LOGGER = LoggerFactory.getLogger(NettyServer.class);
private static final long DEFAULT_COMPRESSED_CHANNEL_WRITE_LIMIT = 600_000L; private static final long DEFAULT_COMPRESSED_CHANNEL_WRITE_LIMIT = 600_000L;
private static final long DEFAULT_COMPRESSED_CHANNEL_READ_LIMIT = 100_000L; private static final long DEFAULT_COMPRESSED_CHANNEL_READ_LIMIT = 100_000L;
private static final Logger log = LoggerFactory.getLogger(NettyServer.class);
private static final long DEFAULT_UNCOMPRESSED_CHANNEL_WRITE_LIMIT = 15_000_000L; private static final long DEFAULT_UNCOMPRESSED_CHANNEL_WRITE_LIMIT = 15_000_000L;
private static final long DEFAULT_UNCOMPRESSED_CHANNEL_READ_LIMIT = 1_000_000L; private static final long DEFAULT_UNCOMPRESSED_CHANNEL_READ_LIMIT = 1_000_000L;
@ -79,28 +79,28 @@ public final class NettyServer {
channel = IOUringServerSocketChannel.class; channel = IOUringServerSocketChannel.class;
log.info("Using Io_uring"); LOGGER.info("Using io_uring");
} else if (Epoll.isAvailable()) { } else if (Epoll.isAvailable()) {
boss = new EpollEventLoopGroup(2); boss = new EpollEventLoopGroup(2);
worker = new EpollEventLoopGroup(); // thread count = core * 2 worker = new EpollEventLoopGroup(); // thread count = core * 2
channel = EpollServerSocketChannel.class; channel = EpollServerSocketChannel.class;
log.info("Using Epoll"); LOGGER.info("Using epoll");
} else if (KQueue.isAvailable()) { } else if (KQueue.isAvailable()) {
boss = new KQueueEventLoopGroup(2); boss = new KQueueEventLoopGroup(2);
worker = new KQueueEventLoopGroup(); // thread count = core * 2 worker = new KQueueEventLoopGroup(); // thread count = core * 2
channel = KQueueServerSocketChannel.class; channel = KQueueServerSocketChannel.class;
log.info("Using KQueue"); LOGGER.info("Using kqueue");
} else { } else {
boss = new NioEventLoopGroup(2); boss = new NioEventLoopGroup(2);
worker = new NioEventLoopGroup(); // thread count = core * 2 worker = new NioEventLoopGroup(); // thread count = core * 2
channel = NioServerSocketChannel.class; channel = NioServerSocketChannel.class;
log.info("Using Nio"); LOGGER.info("Using NIO");
} }
bootstrap = new ServerBootstrap() bootstrap = new ServerBootstrap()

View File

@ -48,9 +48,12 @@ public final class PacketUtils {
final ByteBuf finalBuffer = createFramedPacket(packet, true); final ByteBuf finalBuffer = createFramedPacket(packet, true);
final FramedPacket framedPacket = new FramedPacket(finalBuffer); final FramedPacket framedPacket = new FramedPacket(finalBuffer);
// Prevent premature release
final int refIncrease = players.size() - 1; final int refIncrease = players.size() - 1;
if (refIncrease > 0) if (refIncrease > 0)
finalBuffer.retain(refIncrease); finalBuffer.retain(refIncrease);
// Send packet to all players
for (Player player : players) { for (Player player : players) {
final PlayerConnection playerConnection = player.getPlayerConnection(); final PlayerConnection playerConnection = player.getPlayerConnection();
if (playerConnection instanceof NettyPlayerConnection) { if (playerConnection instanceof NettyPlayerConnection) {