Skip to content

Commit

Permalink
Prefer isolated view
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasa committed Jan 13, 2025
1 parent be82137 commit 8a6a0dd
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions Sources/NIOPosix/Bootstrap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -477,20 +477,17 @@ public final class ServerBootstrap {

@inline(__always)
func fireThroughPipeline(_ future: EventLoopFuture<Void>, context: ChannelHandlerContext) {
// Strictly these asserts are redundant with future.assumeIsolated(), but as this code
// has guarantees that can be quite hard to follow we keep them here.
ctxEventLoop.assertInEventLoop()
assert(ctxEventLoop === context.eventLoop)
let loopBoundValues = NIOLoopBound((context: context, self: self), eventLoop: context.eventLoop)
future.flatMap { (_) -> EventLoopFuture<Void> in
let context = loopBoundValues.value.context
ctxEventLoop.assertInEventLoop()
future.assumeIsolated().flatMap { (_) -> EventLoopFuture<Void> in
guard context.channel.isActive else {
return ctxEventLoop.makeFailedFuture(ChannelError._ioOnClosedChannel)
}
context.fireChannelRead(Self.wrapInboundOut(accepted))
return context.eventLoop.makeSucceededFuture(())
}.whenFailure { error in
let (context, `self`) = loopBoundValues.value
ctxEventLoop.assertInEventLoop()
self.closeAndFire(context: context, accepted: accepted, err: error)
}
}
Expand Down

0 comments on commit 8a6a0dd

Please sign in to comment.