diff --git a/Sources/NIO/BaseSocketChannel.swift b/Sources/NIO/BaseSocketChannel.swift index d44d631f8..af1bdac07 100644 --- a/Sources/NIO/BaseSocketChannel.swift +++ b/Sources/NIO/BaseSocketChannel.swift @@ -842,7 +842,7 @@ class BaseSocketChannel: SelectableChannel, Chan eventLoop.execute { // ensure this is executed in a delayed fashion as the users code may still traverse the pipeline - self.pipeline.removeHandlers() + self.removeHandlers(pipeline: self.pipeline) self.closePromise.succeed(()) diff --git a/Sources/NIO/Channel.swift b/Sources/NIO/Channel.swift index 4708c84d0..076bb20d8 100644 --- a/Sources/NIO/Channel.swift +++ b/Sources/NIO/Channel.swift @@ -310,8 +310,22 @@ extension ChannelCore { /// /// - parameters: /// - channel: The `Channel` whose `ChannelPipeline` will be closed. + @available(*, deprecated, renamed: "removeHandlers(pipeline:)") public func removeHandlers(channel: Channel) { - channel.pipeline.removeHandlers() + self.removeHandlers(pipeline: channel.pipeline) + } + + /// Removes the `ChannelHandler`s from the `ChannelPipeline` `pipeline`, and + /// closes that `ChannelPipeline`. + /// + /// This method is intended for use when writing custom `ChannelCore` implementations. + /// This can be called from `close0` to tear down the `ChannelPipeline` when closure is + /// complete. + /// + /// - parameters: + /// - pipeline: The `ChannelPipline` to be closed. + public func removeHandlers(pipeline: ChannelPipeline) { + pipeline.removeHandlers() } } diff --git a/Sources/NIO/Embedded.swift b/Sources/NIO/Embedded.swift index 335db3739..359b551c5 100644 --- a/Sources/NIO/Embedded.swift +++ b/Sources/NIO/Embedded.swift @@ -281,7 +281,7 @@ class EmbeddedChannelCore: ChannelCore { eventLoop.execute { // ensure this is executed in a delayed fashion as the users code may still traverse the pipeline - self.pipeline.removeHandlers() + self.removeHandlers(pipeline: self.pipeline) self.closePromise.succeed(()) } }