#3781: Fix eventLoopCallback

This commit is contained in:
Valentine 2025-02-08 23:17:16 +02:00 committed by GitHub
parent dd2033bf1a
commit ed4a80eb0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -898,20 +898,26 @@ public class InitialHandler extends PacketHandler implements PendingConnection
// if the event was executed async, we execute the callback on the eventloop again // if the event was executed async, we execute the callback on the eventloop again
// otherwise netty will schedule any pipeline related call by itself, this decreases performance // otherwise netty will schedule any pipeline related call by itself, this decreases performance
private <T> Callback<T> eventLoopCallback(Callback<T> callback) private <T> Callback<T> eventLoopCallback(Callback<T> callback)
{
return (result, error) ->
{ {
EventLoop eventLoop = ch.getHandle().eventLoop(); EventLoop eventLoop = ch.getHandle().eventLoop();
return eventLoop.inEventLoop() ? (result, error) -> if ( eventLoop.inEventLoop() )
{ {
if ( !ch.isClosing() ) if ( !ch.isClosing() )
{ {
callback.done( result, error ); callback.done( result, error );
} }
} : (result, error) -> eventLoop.execute( () -> return;
}
eventLoop.execute( () ->
{ {
if ( !ch.isClosing() ) if ( !ch.isClosing() )
{ {
callback.done( result, error ); callback.done( result, error );
} }
} ); } );
};
} }
} }