diff --git a/transport-native-epoll/src/main/java/io/netty/channel/epoll/Epoll.java b/transport-native-epoll/src/main/java/io/netty/channel/epoll/Epoll.java index 44ba7f6779e..69620b12a43 100644 --- a/transport-native-epoll/src/main/java/io/netty/channel/epoll/Epoll.java +++ b/transport-native-epoll/src/main/java/io/netty/channel/epoll/Epoll.java @@ -15,6 +15,7 @@ */ package io.netty.channel.epoll; +import io.netty.channel.ChannelOption; import io.netty.channel.unix.FileDescriptor; import io.netty.util.internal.SystemPropertyUtil; @@ -92,6 +93,26 @@ public static Throwable unavailabilityCause() { return UNAVAILABILITY_CAUSE; } + /** + * Returns {@code true} if the epoll native transport is both {@linkplain #isAvailable() available} and supports + * {@linkplain ChannelOption#TCP_FASTOPEN_CONNECT client-side TCP FastOpen}. + * + * @return {@code true} if it's possible to use client-side TCP FastOpen via epoll, otherwise {@code false}. + */ + public static boolean isTcpFastOpenClientSideAvailable() { + return isAvailable() && Native.IS_SUPPORTING_TCP_FASTOPEN_CLIENT; + } + + /** + * Returns {@code true} if the epoll native transport is both {@linkplain #isAvailable() available} and supports + * {@linkplain ChannelOption#TCP_FASTOPEN server-side TCP FastOpen}. + * + * @return {@code true} if it's possible to use server-side TCP FastOpen via epoll, otherwise {@code false}. + */ + public static boolean isTcpFastOpenServerSideAvailable() { + return isAvailable() && Native.IS_SUPPORTING_TCP_FASTOPEN_SERVER; + } + private Epoll() { } } diff --git a/transport-native-epoll/src/main/java/io/netty/channel/epoll/Native.java b/transport-native-epoll/src/main/java/io/netty/channel/epoll/Native.java index 8a409dd108f..018f7ff8dee 100644 --- a/transport-native-epoll/src/main/java/io/netty/channel/epoll/Native.java +++ b/transport-native-epoll/src/main/java/io/netty/channel/epoll/Native.java @@ -128,7 +128,8 @@ public void run() { static final boolean IS_SUPPORTING_TCP_FASTOPEN_SERVER = (TCP_FASTOPEN_MODE & TFO_ENABLED_SERVER_MASK) == TFO_ENABLED_SERVER_MASK; /** - * @deprecated Use {@link #IS_SUPPORTING_TCP_FASTOPEN_CLIENT} or {@link #IS_SUPPORTING_TCP_FASTOPEN_SERVER}. + * @deprecated Use {@link Epoll#isTcpFastOpenClientSideAvailable()} + * or {@link Epoll#isTcpFastOpenServerSideAvailable()}. */ @Deprecated public static final boolean IS_SUPPORTING_TCP_FASTOPEN = IS_SUPPORTING_TCP_FASTOPEN_CLIENT ||