Skip to content

Commit

Permalink
Rename IoOpts to IoOps (#14021)
Browse files Browse the repository at this point in the history
Motivation:

#14020 introduced a new way how
registrations are done. Unfortunally there was a type and so interfaces
/ classes were named incorrectly.

Modifications:

- Rename *IoOpts to *IoOps

Result:

Correct spelling
  • Loading branch information
normanmaurer committed Apr 30, 2024
1 parent 7805e3e commit 45b82b0
Show file tree
Hide file tree
Showing 35 changed files with 225 additions and 225 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,7 @@
<item>
<ignore>true</ignore>
<code>java.method.finalMethodAddedToNonFinalClass</code>
<new>method io.netty.util.concurrent.Future&lt;io.netty.channel.IoRegistration&gt; io.netty.channel.SingleThreadIoEventLoop::register(io.netty.channel.IoHandle, io.netty.channel.IoOpt) @ io.netty.channel.epoll.EpollEventLoop</new>
<new>method io.netty.util.concurrent.Future&lt;io.netty.channel.IoRegistration&gt; io.netty.channel.SingleThreadIoEventLoop::register(io.netty.channel.IoHandle, io.netty.channel.IoOps) @ io.netty.channel.epoll.EpollEventLoop</new>
</item>

<item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import io.netty.channel.ConnectTimeoutException;
import io.netty.channel.EventLoop;
import io.netty.channel.IoEventLoop;
import io.netty.channel.IoOpt;
import io.netty.channel.IoOps;
import io.netty.channel.IoRegistration;
import io.netty.channel.RecvByteBufAllocator;
import io.netty.channel.socket.ChannelInputShutdownEvent;
Expand Down Expand Up @@ -75,10 +75,10 @@ abstract class AbstractEpollChannel extends AbstractChannel implements UnixChann
private EpollIoRegistration registration;
boolean inputClosedSeenErrorOnRead;
boolean epollInReadyRunnablePending;
volatile EpollIoOpt initialOpts;
volatile EpollIoOps initialOps;
protected volatile boolean active;

AbstractEpollChannel(Channel parent, LinuxSocket fd, boolean active, EpollIoOpt initialOpts) {
AbstractEpollChannel(Channel parent, LinuxSocket fd, boolean active, EpollIoOps initialOps) {
super(parent);
this.socket = checkNotNull(fd, "fd");
this.active = active;
Expand All @@ -88,18 +88,18 @@ abstract class AbstractEpollChannel extends AbstractChannel implements UnixChann
this.local = fd.localAddress();
this.remote = fd.remoteAddress();
}
this.initialOpts = initialOpts;
this.initialOps = initialOps;
}

AbstractEpollChannel(Channel parent, LinuxSocket fd, SocketAddress remote, EpollIoOpt initialOpts) {
AbstractEpollChannel(Channel parent, LinuxSocket fd, SocketAddress remote, EpollIoOps initialOps) {
super(parent);
this.socket = checkNotNull(fd, "fd");
this.active = true;
// Directly cache the remote and local addresses
// See https://github.com/netty/netty/issues/2359
this.remote = remote;
this.local = fd.localAddress();
this.initialOpts = initialOpts;
this.initialOps = initialOps;
}

static boolean isSoErrorZero(Socket fd) {
Expand All @@ -113,16 +113,16 @@ static boolean isSoErrorZero(Socket fd) {
protected void setFlag(int flag) throws IOException {
if (isRegistered()) {
EpollIoRegistration registration = registration();
registration.updateInterestOpt(registration.interestOpt().with(EpollIoOpt.valueOf(flag)));
registration.updateInterestOpt(registration.interestOpt().with(EpollIoOps.valueOf(flag)));
} else {
initialOpts = initialOpts.with(EpollIoOpt.valueOf(flag));
initialOps = initialOps.with(EpollIoOps.valueOf(flag));
}
}

void clearFlag(int flag) throws IOException {
EpollIoRegistration registration = registration();
registration.updateInterestOpt(
registration.interestOpt().without(EpollIoOpt.valueOf(flag)));
registration.interestOpt().without(EpollIoOps.valueOf(flag)));
}

protected final EpollIoRegistration registration() {
Expand Down Expand Up @@ -278,7 +278,7 @@ public void run() {
} else {
// The EventLoop is not registered atm so just update the flags so the correct value
// will be used once the channel is registered
initialOpts = initialOpts.without(EpollIoOpt.EPOLLIN);
initialOps = initialOps.without(EpollIoOps.EPOLLIN);
}
}

Expand All @@ -288,7 +288,7 @@ protected void doRegister(ChannelPromise promise) {
// make sure the epollInReadyRunnablePending variable is reset so we will be able to execute the Runnable on the
// new EventLoop.
epollInReadyRunnablePending = false;
((IoEventLoop) eventLoop()).register((AbstractEpollUnsafe) unsafe(), initialOpts).addListener(f -> {
((IoEventLoop) eventLoop()).register((AbstractEpollUnsafe) unsafe(), initialOps).addListener(f -> {
if (f.isSuccess()) {
registration = (EpollIoRegistration) f.getNow();
promise.setSuccess();
Expand Down Expand Up @@ -451,8 +451,8 @@ public void close() {
}

@Override
public void handle(IoRegistration registration, IoOpt readyOpt) {
EpollIoOpt epollOpt = (EpollIoOpt) readyOpt;
public void handle(IoRegistration registration, IoOps readyOpt) {
EpollIoOps epollOpt = (EpollIoOps) readyOpt;

// Don't change the ordering of processing EPOLLOUT | EPOLLRDHUP / EPOLLIN if you're not 100%
// sure about it!
Expand All @@ -467,7 +467,7 @@ public void handle(IoRegistration registration, IoOpt readyOpt) {
// In either case epollOutReady() will do the correct thing (finish connecting, or fail
// the connection).
// See https://github.com/netty/netty/issues/3848
if (epollOpt.contains(EpollIoOpt.EPOLLERR) || epollOpt.contains(EpollIoOpt.EPOLLOUT)) {
if (epollOpt.contains(EpollIoOps.EPOLLERR) || epollOpt.contains(EpollIoOps.EPOLLOUT)) {
// Force flush of data as the epoll is writable again
epollOutReady();
}
Expand All @@ -477,15 +477,15 @@ public void handle(IoRegistration registration, IoOpt readyOpt) {
//
// If EPOLLIN or EPOLLERR was received and the channel is still open call epollInReady(). This will
// try to read from the underlying file descriptor and so notify the user about the error.
if (epollOpt.contains(EpollIoOpt.EPOLLERR) || epollOpt.contains(EpollIoOpt.EPOLLIN)) {
if (epollOpt.contains(EpollIoOps.EPOLLERR) || epollOpt.contains(EpollIoOps.EPOLLIN)) {
// The Channel is still open and there is something to read. Do it now.
epollInReady();
}

// Check if EPOLLRDHUP was set, this will notify us for connection-reset in which case
// we may close the channel directly or try to read more data depending on the state of the
// Channel and als depending on the AbstractEpollChannel subtype.
if (epollOpt.contains(EpollIoOpt.EPOLLRDHUP)) {
if (epollOpt.contains(EpollIoOps.EPOLLRDHUP)) {
epollRdHupReady();
}
}
Expand Down Expand Up @@ -640,7 +640,7 @@ protected final void clearEpollIn0() {
try {
readPending = false;
EpollIoRegistration registration = registration();
registration.updateInterestOpt(registration.interestOpt().without(EpollIoOpt.EPOLLIN));
registration.updateInterestOpt(registration.interestOpt().without(EpollIoOps.EPOLLIN));
} catch (IOException e) {
// When this happens there is something completely wrong with either the filedescriptor or epoll,
// so fire the exception through the pipeline and close the Channel.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected AbstractEpollServerChannel(LinuxSocket fd) {
}

protected AbstractEpollServerChannel(LinuxSocket fd, boolean active) {
super(null, fd, active, EpollIoOpt.valueOf(0));
super(null, fd, active, EpollIoOps.valueOf(0));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@ protected AbstractEpollStreamChannel(int fd) {

AbstractEpollStreamChannel(Channel parent, LinuxSocket fd) {
// Add EPOLLRDHUP so we are notified once the remote peer close the connection.
super(parent, fd, true, EpollIoOpt.EPOLLRDHUP);
super(parent, fd, true, EpollIoOps.EPOLLRDHUP);
}

protected AbstractEpollStreamChannel(Channel parent, LinuxSocket fd, SocketAddress remote) {
// Add EPOLLRDHUP so we are notified once the remote peer close the connection.
super(parent, fd, remote, EpollIoOpt.EPOLLRDHUP);
super(parent, fd, remote, EpollIoOps.EPOLLRDHUP);
}

protected AbstractEpollStreamChannel(LinuxSocket fd, boolean active) {
// Add EPOLLRDHUP so we are notified once the remote peer close the connection.
super(null, fd, active, EpollIoOpt.EPOLLRDHUP);
super(null, fd, active, EpollIoOps.EPOLLRDHUP);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ public EpollChannelConfig setEpollMode(EpollMode mode) {
ObjectUtil.checkNotNull(mode, "mode");

AbstractEpollChannel epollChannel = (AbstractEpollChannel) channel;
EpollIoOpt initial = epollChannel.initialOpts;
EpollIoOps initial = epollChannel.initialOps;
checkChannelNotRegistered();
switch (mode) {
case EDGE_TRIGGERED:
epollChannel.initialOpts = initial.with(EpollIoOpt.EPOLLET);
epollChannel.initialOps = initial.with(EpollIoOps.EPOLLET);
break;
case LEVEL_TRIGGERED:
epollChannel.initialOpts = initial.without(EpollIoOpt.EPOLLET);
epollChannel.initialOps = initial.without(EpollIoOps.EPOLLET);
break;
default:
throw new Error();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public EpollDatagramChannel(int fd) {
}

private EpollDatagramChannel(LinuxSocket fd, boolean active) {
super(null, fd, active, EpollIoOpt.valueOf(0));
super(null, fd, active, EpollIoOps.valueOf(0));
config = new EpollDatagramChannelConfig(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public EpollDomainDatagramChannel(int fd) {
}

private EpollDomainDatagramChannel(LinuxSocket socket, boolean active) {
super(null, socket, active, EpollIoOpt.valueOf(0));
super(null, socket, active, EpollIoOps.valueOf(0));
config = new EpollDomainDatagramChannelConfig(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import io.netty.channel.IoHandle;
import io.netty.channel.IoHandler;
import io.netty.channel.IoHandlerFactory;
import io.netty.channel.IoOpt;
import io.netty.channel.IoOps;
import io.netty.channel.SelectStrategy;
import io.netty.channel.SelectStrategyFactory;
import io.netty.channel.unix.FileDescriptor;
Expand Down Expand Up @@ -140,9 +140,9 @@ private static EpollIoHandle cast(IoHandle handle) {
throw new IllegalArgumentException("IoHandle of type " + StringUtil.simpleClassName(handle) + " not supported");
}

private static EpollIoOpt cast(IoOpt opt) {
if (opt instanceof EpollIoOpt) {
return (EpollIoOpt) opt;
private static EpollIoOps cast(IoOps opt) {
if (opt instanceof EpollIoOps) {
return (EpollIoOps) opt;
}
throw new IllegalArgumentException("IoOpt of type " + StringUtil.simpleClassName(opt) + " not supported");
}
Expand Down Expand Up @@ -260,16 +260,16 @@ private final class DefaultEpollIoRegistration extends AtomicBoolean implements
private final IoEventLoop eventLoop;
final EpollIoHandle handle;

private volatile EpollIoOpt currentOpt;
private volatile EpollIoOps currentOpt;

DefaultEpollIoRegistration(IoEventLoop eventLoop, EpollIoHandle handle, EpollIoOpt initialOpt) {
DefaultEpollIoRegistration(IoEventLoop eventLoop, EpollIoHandle handle, EpollIoOps initialOpt) {
this.eventLoop = eventLoop;
this.handle = handle;
this.currentOpt = initialOpt;
}

@Override
public void updateInterestOpt(EpollIoOpt opt) throws IOException {
public void updateInterestOpt(EpollIoOps opt) throws IOException {
currentOpt = opt;
try {
if (!isValid()) {
Expand All @@ -284,7 +284,7 @@ public void updateInterestOpt(EpollIoOpt opt) throws IOException {
}

@Override
public EpollIoOpt interestOpt() {
public EpollIoOps interestOpt() {
return currentOpt;
}

Expand Down Expand Up @@ -342,16 +342,16 @@ void close() {
}

void handle(long ev) {
handle.handle(this, EpollIoOpt.valueOf((int) ev));
handle.handle(this, EpollIoOps.valueOf((int) ev));
}
}

@Override
public EpollIoRegistration register(IoEventLoop eventLoop, IoHandle handle,
IoOpt initialOpt)
IoOps initialOpt)
throws Exception {
final EpollIoHandle epollHandle = cast(handle);
EpollIoOpt opt = cast(initialOpt);
EpollIoOps opt = cast(initialOpt);
DefaultEpollIoRegistration registration = new DefaultEpollIoRegistration(eventLoop, epollHandle, opt);
int fd = epollHandle.fd().intValue();
Native.epollCtlAdd(epollFd.intValue(), fd, registration.interestOpt().value);
Expand Down

0 comments on commit 45b82b0

Please sign in to comment.