geforkt von Mirrors/Velocity
Merge pull request 'Implement Velocity PRs #998 #1246 and #1309 (io_uring, tcp_fastopen and PluginMessage race condition fix)' (#3) from io_uring into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #3 Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Commit
2da400a267
@ -52,6 +52,7 @@ netty-codec-haproxy = { module = "io.netty:netty-codec-haproxy", version.ref = "
|
|||||||
netty-codec-http = { module = "io.netty:netty-codec-http", version.ref = "netty" }
|
netty-codec-http = { module = "io.netty:netty-codec-http", version.ref = "netty" }
|
||||||
netty-handler = { module = "io.netty:netty-handler", version.ref = "netty" }
|
netty-handler = { module = "io.netty:netty-handler", version.ref = "netty" }
|
||||||
netty-transport-native-epoll = { module = "io.netty:netty-transport-native-epoll", version.ref = "netty" }
|
netty-transport-native-epoll = { module = "io.netty:netty-transport-native-epoll", version.ref = "netty" }
|
||||||
|
netty-transport-native-iouring = { module = "io.netty.incubator:netty-incubator-transport-native-io_uring", version = "0.0.25.Final" }
|
||||||
netty-transport-native-kqueue = { module = "io.netty:netty-transport-native-kqueue", version.ref = "netty" }
|
netty-transport-native-kqueue = { module = "io.netty:netty-transport-native-kqueue", version.ref = "netty" }
|
||||||
nightconfig = "com.electronwill.night-config:toml:3.6.7"
|
nightconfig = "com.electronwill.night-config:toml:3.6.7"
|
||||||
slf4j = "org.slf4j:slf4j-api:2.0.12"
|
slf4j = "org.slf4j:slf4j-api:2.0.12"
|
||||||
|
@ -108,6 +108,9 @@ dependencies {
|
|||||||
implementation(libs.netty.transport.native.epoll)
|
implementation(libs.netty.transport.native.epoll)
|
||||||
implementation(variantOf(libs.netty.transport.native.epoll) { classifier("linux-x86_64") })
|
implementation(variantOf(libs.netty.transport.native.epoll) { classifier("linux-x86_64") })
|
||||||
implementation(variantOf(libs.netty.transport.native.epoll) { classifier("linux-aarch_64") })
|
implementation(variantOf(libs.netty.transport.native.epoll) { classifier("linux-aarch_64") })
|
||||||
|
implementation(libs.netty.transport.native.iouring)
|
||||||
|
implementation(variantOf(libs.netty.transport.native.iouring) { classifier("linux-x86_64") })
|
||||||
|
implementation(variantOf(libs.netty.transport.native.iouring) { classifier("linux-aarch_64") })
|
||||||
implementation(libs.netty.transport.native.kqueue)
|
implementation(libs.netty.transport.native.kqueue)
|
||||||
implementation(variantOf(libs.netty.transport.native.kqueue) { classifier("osx-x86_64") })
|
implementation(variantOf(libs.netty.transport.native.kqueue) { classifier("osx-x86_64") })
|
||||||
implementation(variantOf(libs.netty.transport.native.kqueue) { classifier("osx-aarch_64") })
|
implementation(variantOf(libs.netty.transport.native.kqueue) { classifier("osx-aarch_64") })
|
||||||
|
@ -137,12 +137,14 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
|
|||||||
smc.setActiveSessionHandler(StateRegistry.PLAY,
|
smc.setActiveSessionHandler(StateRegistry.PLAY,
|
||||||
new BackendPlaySessionHandler(server, serverConn));
|
new BackendPlaySessionHandler(server, serverConn));
|
||||||
|
|
||||||
// Clean up disabling auto-read while the connected event was being processed.
|
|
||||||
smc.setAutoReading(true);
|
|
||||||
|
|
||||||
// Now set the connected server.
|
// Now set the connected server.
|
||||||
serverConn.getPlayer().setConnectedServer(serverConn);
|
serverConn.getPlayer().setConnectedServer(serverConn);
|
||||||
|
|
||||||
|
// Clean up disabling auto-read while the connected event was being processed.
|
||||||
|
// Do this after setting the connection, so no incoming packets are processed before
|
||||||
|
// the API knows which server the player is connected to.
|
||||||
|
smc.setAutoReading(true);
|
||||||
|
|
||||||
// Send client settings. In 1.20.2+ this is done in the config state.
|
// Send client settings. In 1.20.2+ this is done in the config state.
|
||||||
if (smc.getProtocolVersion().lessThan(ProtocolVersion.MINECRAFT_1_20_2)
|
if (smc.getProtocolVersion().lessThan(ProtocolVersion.MINECRAFT_1_20_2)
|
||||||
&& player.getClientSettingsPacket() != null) {
|
&& player.getClientSettingsPacket() != null) {
|
||||||
|
@ -100,7 +100,7 @@ public final class ConnectionManager {
|
|||||||
.childOption(ChannelOption.IP_TOS, 0x18)
|
.childOption(ChannelOption.IP_TOS, 0x18)
|
||||||
.localAddress(address);
|
.localAddress(address);
|
||||||
|
|
||||||
if (server.getConfiguration().useTcpFastOpen()) {
|
if (transportType.supportsTcpFastOpenServer() && server.getConfiguration().useTcpFastOpen()) {
|
||||||
bootstrap.option(ChannelOption.TCP_FASTOPEN, 3);
|
bootstrap.option(ChannelOption.TCP_FASTOPEN, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ public final class ConnectionManager {
|
|||||||
this.server.getConfiguration().getConnectTimeout())
|
this.server.getConfiguration().getConnectTimeout())
|
||||||
.group(group == null ? this.workerGroup : group)
|
.group(group == null ? this.workerGroup : group)
|
||||||
.resolver(this.resolver.asGroup());
|
.resolver(this.resolver.asGroup());
|
||||||
if (server.getConfiguration().useTcpFastOpen()) {
|
if (transportType.supportsTcpFastOpenClient() && server.getConfiguration().useTcpFastOpen()) {
|
||||||
bootstrap.option(ChannelOption.TCP_FASTOPEN_CONNECT, true);
|
bootstrap.option(ChannelOption.TCP_FASTOPEN_CONNECT, true);
|
||||||
}
|
}
|
||||||
return bootstrap;
|
return bootstrap;
|
||||||
|
@ -37,6 +37,8 @@ import io.netty.channel.socket.SocketChannel;
|
|||||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||||
|
import io.netty.incubator.channel.uring.*;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
@ -47,32 +49,50 @@ public enum TransportType {
|
|||||||
NIO("NIO", NioServerSocketChannel::new,
|
NIO("NIO", NioServerSocketChannel::new,
|
||||||
NioSocketChannel::new,
|
NioSocketChannel::new,
|
||||||
NioDatagramChannel::new,
|
NioDatagramChannel::new,
|
||||||
(name, type) -> new NioEventLoopGroup(0, createThreadFactory(name, type))),
|
(name, type) -> new NioEventLoopGroup(0, createThreadFactory(name, type)),
|
||||||
|
false,
|
||||||
|
false),
|
||||||
EPOLL("epoll", EpollServerSocketChannel::new,
|
EPOLL("epoll", EpollServerSocketChannel::new,
|
||||||
EpollSocketChannel::new,
|
EpollSocketChannel::new,
|
||||||
EpollDatagramChannel::new,
|
EpollDatagramChannel::new,
|
||||||
(name, type) -> new EpollEventLoopGroup(0, createThreadFactory(name, type))),
|
(name, type) -> new EpollEventLoopGroup(0, createThreadFactory(name, type)),
|
||||||
|
Epoll.isTcpFastOpenServerSideAvailable(),
|
||||||
|
Epoll.isTcpFastOpenClientSideAvailable()),
|
||||||
|
IO_URING("io_uring", IOUringServerSocketChannel::new,
|
||||||
|
IOUringSocketChannel::new,
|
||||||
|
IOUringDatagramChannel::new,
|
||||||
|
(name, type) -> new IOUringEventLoopGroup(0, createThreadFactory(name, type)),
|
||||||
|
IOUring.isTcpFastOpenServerSideAvailable(),
|
||||||
|
IOUring.isTcpFastOpenClientSideAvailable()),
|
||||||
KQUEUE("kqueue", KQueueServerSocketChannel::new,
|
KQUEUE("kqueue", KQueueServerSocketChannel::new,
|
||||||
KQueueSocketChannel::new,
|
KQueueSocketChannel::new,
|
||||||
KQueueDatagramChannel::new,
|
KQueueDatagramChannel::new,
|
||||||
(name, type) -> new KQueueEventLoopGroup(0, createThreadFactory(name, type)));
|
(name, type) -> new KQueueEventLoopGroup(0, createThreadFactory(name, type)),
|
||||||
|
KQueue.isTcpFastOpenServerSideAvailable(),
|
||||||
|
KQueue.isTcpFastOpenClientSideAvailable());
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
final ChannelFactory<? extends ServerSocketChannel> serverSocketChannelFactory;
|
final ChannelFactory<? extends ServerSocketChannel> serverSocketChannelFactory;
|
||||||
final ChannelFactory<? extends SocketChannel> socketChannelFactory;
|
final ChannelFactory<? extends SocketChannel> socketChannelFactory;
|
||||||
final ChannelFactory<? extends DatagramChannel> datagramChannelFactory;
|
final ChannelFactory<? extends DatagramChannel> datagramChannelFactory;
|
||||||
final BiFunction<String, Type, EventLoopGroup> eventLoopGroupFactory;
|
final BiFunction<String, Type, EventLoopGroup> eventLoopGroupFactory;
|
||||||
|
final boolean supportsTcpFastOpenServer;
|
||||||
|
final boolean supportsTcpFastOpenClient;
|
||||||
|
|
||||||
TransportType(final String name,
|
TransportType(final String name,
|
||||||
final ChannelFactory<? extends ServerSocketChannel> serverSocketChannelFactory,
|
final ChannelFactory<? extends ServerSocketChannel> serverSocketChannelFactory,
|
||||||
final ChannelFactory<? extends SocketChannel> socketChannelFactory,
|
final ChannelFactory<? extends SocketChannel> socketChannelFactory,
|
||||||
final ChannelFactory<? extends DatagramChannel> datagramChannelFactory,
|
final ChannelFactory<? extends DatagramChannel> datagramChannelFactory,
|
||||||
final BiFunction<String, Type, EventLoopGroup> eventLoopGroupFactory) {
|
final BiFunction<String, Type, EventLoopGroup> eventLoopGroupFactory,
|
||||||
|
final boolean supportsTcpFastOpenServer,
|
||||||
|
final boolean supportsTcpFastOpenClient) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.serverSocketChannelFactory = serverSocketChannelFactory;
|
this.serverSocketChannelFactory = serverSocketChannelFactory;
|
||||||
this.socketChannelFactory = socketChannelFactory;
|
this.socketChannelFactory = socketChannelFactory;
|
||||||
this.datagramChannelFactory = datagramChannelFactory;
|
this.datagramChannelFactory = datagramChannelFactory;
|
||||||
this.eventLoopGroupFactory = eventLoopGroupFactory;
|
this.eventLoopGroupFactory = eventLoopGroupFactory;
|
||||||
|
this.supportsTcpFastOpenServer = supportsTcpFastOpenServer;
|
||||||
|
this.supportsTcpFastOpenClient = supportsTcpFastOpenClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -84,6 +104,14 @@ public enum TransportType {
|
|||||||
return this.eventLoopGroupFactory.apply(this.name, type);
|
return this.eventLoopGroupFactory.apply(this.name, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean supportsTcpFastOpenServer() {
|
||||||
|
return supportsTcpFastOpenServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean supportsTcpFastOpenClient() {
|
||||||
|
return supportsTcpFastOpenClient;
|
||||||
|
}
|
||||||
|
|
||||||
private static ThreadFactory createThreadFactory(final String name, final Type type) {
|
private static ThreadFactory createThreadFactory(final String name, final Type type) {
|
||||||
return new VelocityNettyThreadFactory("Netty " + name + ' ' + type.toString() + " #%d");
|
return new VelocityNettyThreadFactory("Netty " + name + ' ' + type.toString() + " #%d");
|
||||||
}
|
}
|
||||||
@ -98,6 +126,10 @@ public enum TransportType {
|
|||||||
return NIO;
|
return NIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(IOUring.isAvailable()) {
|
||||||
|
return IO_URING;
|
||||||
|
}
|
||||||
|
|
||||||
if (Epoll.isAvailable()) {
|
if (Epoll.isAvailable()) {
|
||||||
return EPOLL;
|
return EPOLL;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren