GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Prevent ManualEventLoop to block on a racy task submission by franz1981 · Pull Request #15937 · netty/netty

Prevent ManualEventLoop to block on a racy task submission #15937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
normanmaurer merged 8 commits into netty:4.2 from franz1981:4.2_epoll_manual
Dec 9, 2025

Uh oh!

There was an error while loading. Please reload this page.

Merged

Prevent ManualEventLoop to block on a racy task submission #15937

Changes from 1 commit
Commits
Show all changes
8 commits
Select commit Hold shift + click to select a range
dcab167
Prevent ManualEventLoop to block on a racy task submission
franz1981 Nov 24, 2025
3c31887
address comment
franz1981 Nov 27, 2025
3a7429c
final all the things
franz1981 Nov 27, 2025
83f6367
private tests
franz1981 Nov 27, 2025
09d179d
fix codestyle
franz1981 Nov 27, 2025
85beafd
Fix Long.MAX_VALUE delays and wrapping
franz1981 Nov 28, 2025
e9a53d7
Fix revapi
franz1981 Nov 28, 2025
bf9d0b5
Fix revapi
franz1981 Nov 28, 2025
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
final all the things
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@franz1981
franz1981 committed Nov 27, 2025
commit 3a7429c73b233aa6c36170c5964bf8e07170f32c

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

58 changes: 29 additions & 29 deletions 58 transport/src/main/java/io/netty/channel/ManualIoEventLoop.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public ManualIoEventLoop(IoEventLoopGroup parent, Thread owningThread, IoHandler
}

@Override
public Ticker ticker() {
public final Ticker ticker() {
return ticker;
}

Expand All @@ -165,7 +165,7 @@ public Ticker ticker() {
*
* @param timeoutNanos the maximum time in nanoseconds to run tasks.
*/
public int runNonBlockingTasks(long timeoutNanos) {
public final int runNonBlockingTasks(long timeoutNanos) {
return runAllTasks(timeoutNanos, true);
}

Expand Down Expand Up @@ -277,7 +277,7 @@ private int runAllTasksBeforeDestroy() {
* @return the number of IO and tasks executed.
* @throws IllegalStateException if the method is not called from the owning {@link Thread}.
*/
public int runNow(long runAllTasksTimeoutNanos) {
public final int runNow(long runAllTasksTimeoutNanos) {
checkCurrentThread();
return run(nonBlockingContext, runAllTasksTimeoutNanos);
}
Expand All @@ -291,7 +291,7 @@ public int runNow(long runAllTasksTimeoutNanos) {
*
* @return the number of IO and tasks executed.
*/
public int runNow() {
public final int runNow() {
checkCurrentThread();
return run(nonBlockingContext, 0);
}
Expand All @@ -310,7 +310,7 @@ public int runNow() {
* if there is nothing to run (like {@link #runNow()}).
* @return the number of IO and tasks executed.
*/
public int run(long waitNanos, long runAllTasksTimeoutNanos) {
public final int run(long waitNanos, long runAllTasksTimeoutNanos) {
checkCurrentThread();

final IoHandlerContext context;
Expand All @@ -335,7 +335,7 @@ public int run(long waitNanos, long runAllTasksTimeoutNanos) {
* if there is nothing to run (like {@link #runNow()}).
* @return the number of IO and tasks executed.
*/
public int run(long waitNanos) {
public final int run(long waitNanos) {
return run(waitNanos, 0);
}

Expand All @@ -348,39 +348,39 @@ private void checkCurrentThread() {
/**
* Force a wakeup and so the {@link #run(long)} method will unblock and return even if there was nothing to do.
*/
public void wakeup() {
public final void wakeup() {
if (isShuttingDown()) {
return;
}
handler.wakeup();
}

@Override
public ManualIoEventLoop next() {
public final ManualIoEventLoop next() {
return this;
}

@Override
public IoEventLoopGroup parent() {
public final IoEventLoopGroup parent() {
return parent;
}

@Deprecated
@Override
public ChannelFuture register(Channel channel) {
public final ChannelFuture register(Channel channel) {
return register(new DefaultChannelPromise(channel, this));
}

@Deprecated
@Override
public ChannelFuture register(final ChannelPromise promise) {
public final ChannelFuture register(final ChannelPromise promise) {
ObjectUtil.checkNotNull(promise, "promise");
promise.channel().unsafe().register(this, promise);
return promise;
}

@Override
public Future<IoRegistration> register(final IoHandle handle) {
public final Future<IoRegistration> register(final IoHandle handle) {
Promise<IoRegistration> promise = newPromise();
if (inEventLoop()) {
registerForIo0(handle, promise);
Expand All @@ -405,25 +405,25 @@ private void registerForIo0(final IoHandle handle, Promise<IoRegistration> promi

@Deprecated
@Override
public ChannelFuture register(final Channel channel, final ChannelPromise promise) {
public final ChannelFuture register(final Channel channel, final ChannelPromise promise) {
ObjectUtil.checkNotNull(promise, "promise");
ObjectUtil.checkNotNull(channel, "channel");
channel.unsafe().register(this, promise);
return promise;
}

@Override
public boolean isCompatible(Class<? extends IoHandle> handleType) {
public final boolean isCompatible(Class<? extends IoHandle> handleType) {
return handler.isCompatible(handleType);
}

@Override
public boolean isIoType(Class<? extends IoHandler> handlerType) {
public final boolean isIoType(Class<? extends IoHandler> handlerType) {
return handler.getClass().equals(handlerType);
}

@Override
public boolean inEventLoop(Thread thread) {
public final boolean inEventLoop(Thread thread) {
return this.owningThread.get() == thread;
}

Expand All @@ -433,7 +433,7 @@ public boolean inEventLoop(Thread thread) {
*
* @param owningThread The owning thread
*/
public void setOwningThread(Thread owningThread) {
public final void setOwningThread(Thread owningThread) {
Objects.requireNonNull(owningThread, "owningThread");
if (!this.owningThread.compareAndSet(null, owningThread)) {
throw new IllegalStateException("Owning thread already set");
Expand Down Expand Up @@ -479,7 +479,7 @@ private void shutdown0(long quietPeriod, long timeout, int shutdownState) {
}

@Override
public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) {
public final Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) {
ObjectUtil.checkPositiveOrZero(quietPeriod, "quietPeriod");
if (timeout < quietPeriod) {
throw new IllegalArgumentException(
Expand All @@ -493,37 +493,37 @@ public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit uni

@Override
@Deprecated
public void shutdown() {
public final void shutdown() {
shutdown0(-1, -1, ST_SHUTDOWN);
}

@Override
public Future<?> terminationFuture() {
public final Future<?> terminationFuture() {
return terminationFuture;
}

@Override
public boolean isShuttingDown() {
public final boolean isShuttingDown() {
return state.get() >= ST_SHUTTING_DOWN;
}

@Override
public boolean isShutdown() {
public final boolean isShutdown() {
return state.get() >= ST_SHUTDOWN;
}

@Override
public boolean isTerminated() {
public final boolean isTerminated() {
return state.get() == ST_TERMINATED;
}

@Override
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
public final boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
return terminationFuture.await(timeout, unit);
}

@Override
public void execute(Runnable command) {
public final void execute(Runnable command) {
Objects.requireNonNull(command, "command");
boolean inEventLoop = inEventLoop();
if (inEventLoop) {
Expand Down Expand Up @@ -608,30 +608,30 @@ private boolean confirmShutdown() {
}

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
public final <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
// We need to check if the method was called from within the EventLoop as this would cause a deadlock.
throwIfInEventLoop("invokeAny");
return super.invokeAny(tasks);
}

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
public final <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
// We need to check if the method was called from within the EventLoop as this would cause a deadlock.
throwIfInEventLoop("invokeAny");
return super.invokeAny(tasks, timeout, unit);
}

@Override
public <T> List<java.util.concurrent.Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
public final <T> List<java.util.concurrent.Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
throws InterruptedException {
// We need to check if the method was called from within the EventLoop as this would cause a deadlock.
throwIfInEventLoop("invokeAll");
return super.invokeAll(tasks);
}

@Override
public <T> List<java.util.concurrent.Future<T>> invokeAll(
public final <T> List<java.util.concurrent.Future<T>> invokeAll(
Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
// We need to check if the method was called from within the EventLoop as this would cause a deadlock.
throwIfInEventLoop("invokeAll");
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402809 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.