Skip to content

Commit

Permalink
More renames of IoOpts to IoOps (#14025)
Browse files Browse the repository at this point in the history
Motivation:
The interface was renamed in #14021, but many variables, fields,
parameters and method names still referenced "opt".

Modifications:
Extend the rename to the remaining parts of the code.

Result:
Spelling corrected everywhere.
  • Loading branch information
chrisvest committed Apr 30, 2024
1 parent 45b82b0 commit ea6d93a
Show file tree
Hide file tree
Showing 26 changed files with 189 additions and 189 deletions.
Expand Up @@ -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(EpollIoOps.valueOf(flag)));
registration.updateInterestOps(registration.interestOps().with(EpollIoOps.valueOf(flag)));
} else {
initialOps = initialOps.with(EpollIoOps.valueOf(flag));
}
}

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

protected final EpollIoRegistration registration() {
Expand All @@ -131,7 +131,7 @@ protected final EpollIoRegistration registration() {
}

boolean isFlagSet(int flag) {
return (registration().interestOpt().value & flag) != 0;
return (registration().interestOps().value & flag) != 0;
}

@Override
Expand Down Expand Up @@ -451,8 +451,8 @@ public void close() {
}

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

// 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, IoOps 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(EpollIoOps.EPOLLERR) || epollOpt.contains(EpollIoOps.EPOLLOUT)) {
if (epollOps.contains(EpollIoOps.EPOLLERR) || epollOps.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, IoOps 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(EpollIoOps.EPOLLERR) || epollOpt.contains(EpollIoOps.EPOLLIN)) {
if (epollOps.contains(EpollIoOps.EPOLLERR) || epollOps.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(EpollIoOps.EPOLLRDHUP)) {
if (epollOps.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(EpollIoOps.EPOLLIN));
registration.updateInterestOps(registration.interestOps().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
Expand Up @@ -140,11 +140,11 @@ private static EpollIoHandle cast(IoHandle handle) {
throw new IllegalArgumentException("IoHandle of type " + StringUtil.simpleClassName(handle) + " not supported");
}

private static EpollIoOps cast(IoOps opt) {
if (opt instanceof EpollIoOps) {
return (EpollIoOps) opt;
private static EpollIoOps cast(IoOps ops) {
if (ops instanceof EpollIoOps) {
return (EpollIoOps) ops;
}
throw new IllegalArgumentException("IoOpt of type " + StringUtil.simpleClassName(opt) + " not supported");
throw new IllegalArgumentException("IoOps of type " + StringUtil.simpleClassName(ops) + " not supported");
}

/**
Expand Down Expand Up @@ -260,22 +260,22 @@ private final class DefaultEpollIoRegistration extends AtomicBoolean implements
private final IoEventLoop eventLoop;
final EpollIoHandle handle;

private volatile EpollIoOps currentOpt;
private volatile EpollIoOps currentOps;

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

@Override
public void updateInterestOpt(EpollIoOps opt) throws IOException {
currentOpt = opt;
public void updateInterestOps(EpollIoOps ops) throws IOException {
currentOps = ops;
try {
if (!isValid()) {
return;
}
Native.epollCtlMod(epollFd.intValue(), handle.fd().intValue(), opt.value);
Native.epollCtlMod(epollFd.intValue(), handle.fd().intValue(), ops.value);
} catch (IOException e) {
throw e;
} catch (Exception e) {
Expand All @@ -284,8 +284,8 @@ public void updateInterestOpt(EpollIoOps opt) throws IOException {
}

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

@Override
Expand Down Expand Up @@ -348,13 +348,13 @@ void handle(long ev) {

@Override
public EpollIoRegistration register(IoEventLoop eventLoop, IoHandle handle,
IoOps initialOpt)
IoOps initialOps)
throws Exception {
final EpollIoHandle epollHandle = cast(handle);
EpollIoOps opt = cast(initialOpt);
DefaultEpollIoRegistration registration = new DefaultEpollIoRegistration(eventLoop, epollHandle, opt);
EpollIoOps ops = cast(initialOps);
DefaultEpollIoRegistration registration = new DefaultEpollIoRegistration(eventLoop, epollHandle, ops);
int fd = epollHandle.fd().intValue();
Native.epollCtlAdd(epollFd.intValue(), fd, registration.interestOpt().value);
Native.epollCtlAdd(epollFd.intValue(), fd, registration.interestOps().value);
DefaultEpollIoRegistration old = registrations.put(fd, registration);

// We either expect to have no registration in the map with the same FD or that the FD of the old registration
Expand Down
Expand Up @@ -51,21 +51,21 @@ public final class EpollIoOps implements IoOps {
public static final EpollIoOps EPOLLET = new EpollIoOps(Native.EPOLLET);

// Just use an array to store often used values.
private static final EpollIoOps[] OPTS;
private static final EpollIoOps[] OPS;

static {
EpollIoOps all = new EpollIoOps(
EPOLLOUT.value | EPOLLIN.value | EPOLLERR.value | EPOLLRDHUP.value);
OPTS = new EpollIoOps[all.value + 1];
addToArray(OPTS, EPOLLOUT);
addToArray(OPTS, EPOLLIN);
addToArray(OPTS, EPOLLERR);
addToArray(OPTS, EPOLLRDHUP);
addToArray(OPTS, all);
OPS = new EpollIoOps[all.value + 1];
addToArray(OPS, EPOLLOUT);
addToArray(OPS, EPOLLIN);
addToArray(OPS, EPOLLERR);
addToArray(OPS, EPOLLRDHUP);
addToArray(OPS, all);
}

private static void addToArray(EpollIoOps[] array, EpollIoOps opt) {
array[opt.value] = opt;
private static void addToArray(EpollIoOps[] array, EpollIoOps ops) {
array[ops.value] = ops;
}

final int value;
Expand All @@ -76,37 +76,37 @@ private EpollIoOps(int value) {

/**
* Returns {@code true} if this {@link EpollIoOps} is a combination of the given {@link EpollIoOps}.
* @param opt the opt.
* @param ops the ops.
* @return {@code true} if a combination of the given.
*/
public boolean contains(EpollIoOps opt) {
return (value & opt.value) != 0;
public boolean contains(EpollIoOps ops) {
return (value & ops.value) != 0;
}

/**
* Return a {@link EpollIoOps} which is a combination of the current and the given {@link EpollIoOps}.
*
* @param opt the {@link EpollIoOps} that should be added to this one.
* @param ops the {@link EpollIoOps} that should be added to this one.
* @return a {@link EpollIoOps}.
*/
public EpollIoOps with(EpollIoOps opt) {
if (contains(opt)) {
public EpollIoOps with(EpollIoOps ops) {
if (contains(ops)) {
return this;
}
return valueOf(value | opt.value());
return valueOf(value | ops.value());
}

/**
* Return a {@link EpollIoOps} which is not a combination of the current and the given {@link EpollIoOps}.
*
* @param opt the {@link EpollIoOps} that should be remove from this one.
* @param ops the {@link EpollIoOps} that should be remove from this one.
* @return a {@link EpollIoOps}.
*/
public EpollIoOps without(EpollIoOps opt) {
if (!contains(opt)) {
public EpollIoOps without(EpollIoOps ops) {
if (!contains(ops)) {
return this;
}
return valueOf(value & ~opt.value());
return valueOf(value & ~ops.value());
}

/**
Expand All @@ -126,8 +126,8 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
EpollIoOps nioOpt = (EpollIoOps) o;
return value == nioOpt.value;
EpollIoOps nioOps = (EpollIoOps) o;
return value == nioOps.value;
}

@Override
Expand All @@ -142,11 +142,11 @@ public int hashCode() {
* @return the {@link EpollIoOps}.
*/
public static EpollIoOps valueOf(int value) {
final EpollIoOps opt;
if (value > 0 && value < OPTS.length) {
opt = OPTS[value];
if (opt != null) {
return opt;
final EpollIoOps ops;
if (value > 0 && value < OPS.length) {
ops = OPS[value];
if (ops != null) {
return ops;
}
} else if (value == EPOLLET.value) {
return EPOLLET;
Expand Down
Expand Up @@ -26,16 +26,16 @@ public interface EpollIoRegistration extends IoRegistration {
/**
* Update the {@link EpollIoOps} for this registration.
*
* @param opt the {@link EpollIoOps} to use.
* @param ops the {@link EpollIoOps} to use.
*/
void updateInterestOpt(EpollIoOps opt) throws IOException;
void updateInterestOps(EpollIoOps ops) throws IOException;

/**
* The used {@link EpollIoOps} for this registration.
*
* @return opt.
* @return ops.
*/
EpollIoOps interestOpt();
EpollIoOps interestOps();

@Override
void cancel() throws IOException;
Expand Down
Expand Up @@ -73,10 +73,10 @@ abstract class AbstractKQueueChannel extends AbstractChannel implements UnixChan
private boolean readFilterEnabled;
private boolean writeFilterEnabled;

private final KQueueEventIoOps readEnabledOpt;
private final KQueueEventIoOps writeEnabledOpt;
private final KQueueEventIoOps readDisabledOpt;
private final KQueueEventIoOps writeDisabledOpt;
private final KQueueEventIoOps readEnabledOps;
private final KQueueEventIoOps writeEnabledOps;
private final KQueueEventIoOps readDisabledOps;
private final KQueueEventIoOps writeDisabledOps;

boolean readReadyRunnablePending;
boolean inputClosedSeenErrorOnRead;
Expand All @@ -95,10 +95,10 @@ abstract class AbstractKQueueChannel extends AbstractChannel implements UnixChan
remote = fd.remoteAddress();
}

readEnabledOpt = KQueueEventIoOps.newOpt(fd().intValue(), Native.EVFILT_READ, Native.EV_ADD_CLEAR_ENABLE, 0);
writeEnabledOpt = KQueueEventIoOps.newOpt(fd().intValue(), Native.EVFILT_WRITE, Native.EV_ADD_CLEAR_ENABLE, 0);
readDisabledOpt = KQueueEventIoOps.newOpt(fd().intValue(), Native.EVFILT_READ, Native.EV_DELETE_DISABLE, 0);
writeDisabledOpt = KQueueEventIoOps.newOpt(fd().intValue(), Native.EVFILT_WRITE, Native.EV_DELETE_DISABLE, 0);
readEnabledOps = KQueueEventIoOps.newOps(fd().intValue(), Native.EVFILT_READ, Native.EV_ADD_CLEAR_ENABLE, 0);
writeEnabledOps = KQueueEventIoOps.newOps(fd().intValue(), Native.EVFILT_WRITE, Native.EV_ADD_CLEAR_ENABLE, 0);
readDisabledOps = KQueueEventIoOps.newOps(fd().intValue(), Native.EVFILT_READ, Native.EV_DELETE_DISABLE, 0);
writeDisabledOps = KQueueEventIoOps.newOps(fd().intValue(), Native.EVFILT_WRITE, Native.EV_DELETE_DISABLE, 0);
}

AbstractKQueueChannel(Channel parent, BsdSocket fd, SocketAddress remote) {
Expand All @@ -110,10 +110,10 @@ abstract class AbstractKQueueChannel extends AbstractChannel implements UnixChan
this.remote = remote;
local = fd.localAddress();

readEnabledOpt = KQueueEventIoOps.newOpt(fd().intValue(), Native.EVFILT_READ, Native.EV_ADD_CLEAR_ENABLE, 0);
writeEnabledOpt = KQueueEventIoOps.newOpt(fd().intValue(), Native.EVFILT_WRITE, Native.EV_ADD_CLEAR_ENABLE, 0);
readDisabledOpt = KQueueEventIoOps.newOpt(fd().intValue(), Native.EVFILT_READ, Native.EV_DELETE_DISABLE, 0);
writeDisabledOpt = KQueueEventIoOps.newOpt(fd().intValue(), Native.EVFILT_WRITE, Native.EV_DELETE_DISABLE, 0);
readEnabledOps = KQueueEventIoOps.newOps(fd().intValue(), Native.EVFILT_READ, Native.EV_ADD_CLEAR_ENABLE, 0);
writeEnabledOps = KQueueEventIoOps.newOps(fd().intValue(), Native.EVFILT_WRITE, Native.EV_ADD_CLEAR_ENABLE, 0);
readDisabledOps = KQueueEventIoOps.newOps(fd().intValue(), Native.EVFILT_READ, Native.EV_DELETE_DISABLE, 0);
writeDisabledOps = KQueueEventIoOps.newOps(fd().intValue(), Native.EVFILT_WRITE, Native.EV_DELETE_DISABLE, 0);
}

@Override
Expand Down Expand Up @@ -189,7 +189,7 @@ protected void doDeregister() throws Exception {
}

private void clearRdHup0() {
registration.addOpt(KQueueEventIoOps.newOpt(fd().intValue(),
registration.addOps(KQueueEventIoOps.newOps(fd().intValue(),
Native.EVFILT_SOCK, Native.EV_DELETE_DISABLE, Native.NOTE_RDHUP));
}

Expand All @@ -213,9 +213,9 @@ protected final void doBeginRead() throws Exception {

@Override
protected void doRegister(ChannelPromise promise) {
KQueueEventIoOps initialOpt = KQueueEventIoOps.newOpt(
KQueueEventIoOps initialOps = KQueueEventIoOps.newOps(
fd().intValue(), Native.EVFILT_SOCK, Native.EV_ADD, Native.NOTE_RDHUP);
((IoEventLoop) eventLoop()).register((AbstractKQueueUnsafe) unsafe(), initialOpt).addListener(f -> {
((IoEventLoop) eventLoop()).register((AbstractKQueueUnsafe) unsafe(), initialOps).addListener(f -> {
if (f.isSuccess()) {
this.registration = (KQueueIoRegistration) f.getNow();
// Just in case the previous EventLoop was shutdown abruptly, or an event is still pending on the old
Expand All @@ -226,10 +226,10 @@ protected void doRegister(ChannelPromise promise) {
int ident = fd().intValue();
// Add the write event first so we get notified of connection refused on the client side!
if (writeFilterEnabled) {
registration.addOpt(writeEnabledOpt);
registration.addOps(writeEnabledOps);
}
if (readFilterEnabled) {
registration.addOpt(readEnabledOpt);
registration.addOps(readEnabledOps);
}
promise.setSuccess();
} else {
Expand Down Expand Up @@ -372,14 +372,14 @@ public void run() {
void readFilter(boolean readFilterEnabled) throws IOException {
if (this.readFilterEnabled != readFilterEnabled) {
this.readFilterEnabled = readFilterEnabled;
registration().addOpt(readFilterEnabled ? readEnabledOpt : readDisabledOpt);
registration().addOps(readFilterEnabled ? readEnabledOps : readDisabledOps);
}
}

void writeFilter(boolean writeFilterEnabled) throws IOException {
if (this.writeFilterEnabled != writeFilterEnabled) {
this.writeFilterEnabled = writeFilterEnabled;
registration().addOpt(writeFilterEnabled ? writeEnabledOpt : writeDisabledOpt);
registration().addOps(writeFilterEnabled ? writeEnabledOps : writeDisabledOps);
}
}

Expand Down Expand Up @@ -411,12 +411,12 @@ public void close() {
}

@Override
public void handle(IoRegistration registration, IoOps readyOpt) {
KQueueEventIoOps opt = (KQueueEventIoOps) readyOpt;
final short filter = opt.filter();
final short flags = opt.flags();
final int fflags = opt.fflags();
final long data = opt.data();
public void handle(IoRegistration registration, IoOps readyOps) {
KQueueEventIoOps ops = (KQueueEventIoOps) readyOps;
final short filter = ops.filter();
final short flags = ops.flags();
final int fflags = ops.fflags();
final long data = ops.data();

// First check for EPOLLOUT as we may need to fail the connect ChannelPromise before try
// to read from the file descriptor.
Expand Down

0 comments on commit ea6d93a

Please sign in to comment.