From fee84ed63ae7618fabba661cea9d5e1fa96ff74e Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Mon, 12 Mar 2018 21:27:42 +0900 Subject: [PATCH] Revert "make isOpen a computed property (#123)" (#129) This reverts commit 4deeaf6365075781641c149af6e994b0bc78ae1a. --- Sources/NIO/BaseSocket.swift | 10 +- Sources/NIO/FileHandle.swift | 17 +- Tests/NIOTests/BaseObjectsTest.swift | 94 ++++---- Tests/NIOTests/ChannelPipelineTest.swift | 14 +- Tests/NIOTests/ChannelTests.swift | 267 ++++++++++++----------- Tests/NIOTests/TestUtils.swift | 31 +-- 6 files changed, 219 insertions(+), 214 deletions(-) diff --git a/Sources/NIO/BaseSocket.swift b/Sources/NIO/BaseSocket.swift index 215968a96..d44ab8c89 100644 --- a/Sources/NIO/BaseSocket.swift +++ b/Sources/NIO/BaseSocket.swift @@ -204,10 +204,8 @@ extension sockaddr_storage { /// This should not be created directly but one of its sub-classes should be used, like `ServerSocket` or `Socket`. class BaseSocket: Selectable { - private var descriptor: CInt - public var isOpen: Bool { - return descriptor >= 0 - } + private let descriptor: CInt + public private(set) var isOpen: Bool func withUnsafeFileDescriptor(_ body: (CInt) throws -> T) throws -> T { guard self.isOpen else { @@ -285,8 +283,8 @@ class BaseSocket: Selectable { /// - parameters: /// - descriptor: The file descriptor to wrap. init(descriptor: CInt) { - precondition(descriptor >= 0, "invalid file descriptor") self.descriptor = descriptor + self.isOpen = true } deinit { @@ -383,7 +381,7 @@ class BaseSocket: Selectable { try Posix.close(descriptor: fd) } - self.descriptor = -1 + self.isOpen = false } } diff --git a/Sources/NIO/FileHandle.swift b/Sources/NIO/FileHandle.swift index 624da3d38..1beb55d0f 100644 --- a/Sources/NIO/FileHandle.swift +++ b/Sources/NIO/FileHandle.swift @@ -23,17 +23,14 @@ /// /// - warning: `FileHandle` objects are not thread-safe and are mutable. They also cannot be fully thread-safe as they refer to a global underlying file descriptor. public final class FileHandle: FileDescriptor { - private var descriptor: CInt - - public var isOpen: Bool { - return descriptor >= 0 - } + public private(set) var isOpen: Bool + private let descriptor: CInt /// Create a `FileHandle` taking ownership of `descriptor`. You must call `FileHandle.close` or `FileHandle.takeDescriptorOwnership` before /// this object can be safely released. public init(descriptor: CInt) { - precondition(descriptor >= 0, "invalid file descriptor") self.descriptor = descriptor + self.isOpen = true } deinit { @@ -63,16 +60,16 @@ public final class FileHandle: FileDescriptor { throw IOError(errnoCode: EBADF, reason: "can't close file (as it's not open anymore).") } - let savedDescriptor = self.descriptor - self.descriptor = -1 - return savedDescriptor + self.isOpen = false + return self.descriptor } public func close() throws { try withUnsafeFileDescriptor { fd in try Posix.close(descriptor: fd) } - self.descriptor = -1 + + self.isOpen = false } public func withUnsafeFileDescriptor(_ body: (CInt) throws -> T) throws -> T { diff --git a/Tests/NIOTests/BaseObjectsTest.swift b/Tests/NIOTests/BaseObjectsTest.swift index 2f6c934b3..b1833ac3a 100644 --- a/Tests/NIOTests/BaseObjectsTest.swift +++ b/Tests/NIOTests/BaseObjectsTest.swift @@ -50,37 +50,41 @@ class BaseObjectTest: XCTestCase { } } - func testNIOFileRegionConversion() throws { - try withPipe { (readFH, writeFH) in - let expected = FileRegion(fileHandle: readFH, readerIndex: 1, endIndex: 2) - let asAny = NIOAny(expected) - XCTAssert(expected == asAny.forceAs(type: FileRegion.self)) - XCTAssert(expected == asAny.forceAsFileRegion()) - if let actual = asAny.tryAs(type: FileRegion.self) { - XCTAssert(expected == actual) - } else { - XCTFail("tryAs didn't work") - } - if let actual = asAny.tryAsFileRegion() { - XCTAssert(expected == actual) - } else { - XCTFail("tryAs didn't work") - } - return [readFH, writeFH] + func testNIOFileRegionConversion() { + let handle = FileHandle(descriptor: -1) + let expected = FileRegion(fileHandle: handle, readerIndex: 1, endIndex: 2) + defer { + // fake descriptor, so shouldn't be closed. + XCTAssertNoThrow(try handle.takeDescriptorOwnership()) + } + let asAny = NIOAny(expected) + XCTAssert(expected == asAny.forceAs(type: FileRegion.self)) + XCTAssert(expected == asAny.forceAsFileRegion()) + if let actual = asAny.tryAs(type: FileRegion.self) { + XCTAssert(expected == actual) + } else { + XCTFail("tryAs didn't work") + } + if let actual = asAny.tryAsFileRegion() { + XCTAssert(expected == actual) + } else { + XCTFail("tryAs didn't work") } } - func testBadConversions() throws { - try withPipe { (readFH, writeFH) in - let bb = ByteBufferAllocator().buffer(capacity: 1024) - let fr = FileRegion(fileHandle: readFH, readerIndex: 1, endIndex: 2) - let id = IOData.byteBuffer(bb) - - XCTAssertNil(NIOAny(bb).tryAsFileRegion()) - XCTAssertNil(NIOAny(fr).tryAsByteBuffer()) - XCTAssertNil(NIOAny(id).tryAsFileRegion()) - return [readFH, writeFH] + func testBadConversions() { + let handle = FileHandle(descriptor: -1) + let bb = ByteBufferAllocator().buffer(capacity: 1024) + let fr = FileRegion(fileHandle: handle, readerIndex: 1, endIndex: 2) + defer { + // fake descriptor, so shouldn't be closed. + XCTAssertNoThrow(try handle.takeDescriptorOwnership()) } + let id = IOData.byteBuffer(bb) + + XCTAssertNil(NIOAny(bb).tryAsFileRegion()) + XCTAssertNil(NIOAny(fr).tryAsByteBuffer()) + XCTAssertNil(NIOAny(id).tryAsFileRegion()) } func testByteBufferFromIOData() { @@ -89,25 +93,29 @@ class BaseObjectTest: XCTestCase { XCTAssertEqual(expected, NIOAny(wrapped).tryAsByteBuffer()) } - func testFileRegionFromIOData() throws { - try withPipe { (readFH, writeFH) in - let expected = FileRegion(fileHandle: readFH, readerIndex: 1, endIndex: 2) - let wrapped = IOData.fileRegion(expected) - XCTAssert(expected == NIOAny(wrapped).tryAsFileRegion()) - return [readFH, writeFH] + func testFileRegionFromIOData() { + let handle = FileHandle(descriptor: -1) + let expected = FileRegion(fileHandle: handle, readerIndex: 1, endIndex: 2) + defer { + // fake descriptor, so shouldn't be closed. + XCTAssertNoThrow(try handle.takeDescriptorOwnership()) } + let wrapped = IOData.fileRegion(expected) + XCTAssert(expected == NIOAny(wrapped).tryAsFileRegion()) } - func testIODataEquals() throws { - try withPipe { (readFH, writeFH) in - var bb1 = ByteBufferAllocator().buffer(capacity: 1024) - let bb2 = ByteBufferAllocator().buffer(capacity: 1024) - bb1.write(string: "hello") - let fr = FileRegion(fileHandle: readFH, readerIndex: 1, endIndex: 2) - XCTAssertEqual(IOData.byteBuffer(bb1), IOData.byteBuffer(bb1)) - XCTAssertNotEqual(IOData.byteBuffer(bb1), IOData.byteBuffer(bb2)) - XCTAssertNotEqual(IOData.byteBuffer(bb1), IOData.fileRegion(fr)) - return [readFH, writeFH] + func testIODataEquals() { + let handle = FileHandle(descriptor: -1) + var bb1 = ByteBufferAllocator().buffer(capacity: 1024) + let bb2 = ByteBufferAllocator().buffer(capacity: 1024) + bb1.write(string: "hello") + let fr = FileRegion(fileHandle: handle, readerIndex: 1, endIndex: 2) + defer { + // fake descriptor, so shouldn't be closed. + XCTAssertNoThrow(try handle.takeDescriptorOwnership()) } + XCTAssertEqual(IOData.byteBuffer(bb1), IOData.byteBuffer(bb1)) + XCTAssertNotEqual(IOData.byteBuffer(bb1), IOData.byteBuffer(bb2)) + XCTAssertNotEqual(IOData.byteBuffer(bb1), IOData.fileRegion(fr)) } } diff --git a/Tests/NIOTests/ChannelPipelineTest.swift b/Tests/NIOTests/ChannelPipelineTest.swift index 71a70e780..5a12dc867 100644 --- a/Tests/NIOTests/ChannelPipelineTest.swift +++ b/Tests/NIOTests/ChannelPipelineTest.swift @@ -165,13 +165,15 @@ class ChannelPipelineTest: XCTestCase { XCTAssertTrue(loop.inEventLoop) do { - try withPipe { (readFH, writeFH) in - let fr = FileRegion(fileHandle: writeFH, readerIndex: 0, endIndex: 0) - try channel.writeOutbound(fr) - loop.run() - XCTFail("we ran but an error should have been thrown") - return [readFH, writeFH] + let handle = FileHandle(descriptor: -1) + let fr = FileRegion(fileHandle: handle, readerIndex: 0, endIndex: 0) + defer { + // fake descriptor, so shouldn't be closed. + XCTAssertNoThrow(try handle.takeDescriptorOwnership()) } + try channel.writeOutbound(fr) + loop.run() + XCTFail("we ran but an error should have been thrown") } catch let err as ChannelError { XCTAssertEqual(err, .ioOnClosedChannel) } diff --git a/Tests/NIOTests/ChannelTests.swift b/Tests/NIOTests/ChannelTests.swift index 557738b8d..e84f19b38 100644 --- a/Tests/NIOTests/ChannelTests.swift +++ b/Tests/NIOTests/ChannelTests.swift @@ -15,6 +15,7 @@ import XCTest @testable import NIO + class ChannelLifecycleHandler: ChannelInboundHandler { public typealias InboundIn = Any @@ -596,30 +597,32 @@ public class ChannelTests: XCTestCase { let numberOfWrites = Int(1 /* first write */ + pwm.writeSpinCount /* the spins */ + 1 /* so one byte remains at the end */) buffer.clear() buffer.write(bytes: Array(repeating: 0xff, count: 1)) - try withPipe { (readFH, writeFH) in - let fileRegion = FileRegion(fileHandle: writeFH, readerIndex: 0, endIndex: 1) - let ps: [EventLoopPromise<()>] = (0..] = (0..] = (0..<2).map { (_: Int) in el.newPromise() } - try withSocketpair { ( fh1, fh2) in - let fr1 = FileRegion(fileHandle: fh1, readerIndex: 12, endIndex: 14) - let fr2 = FileRegion(fileHandle: fh2, readerIndex: 0, endIndex: 2) - _ = pwm.add(data: .fileRegion(fr1), promise: ps[0]) - pwm.markFlushCheckpoint() - _ = pwm.add(data: .fileRegion(fr2), promise: ps[1]) - var result = try assertExpectedWritability(pendingWritesManager: pwm, - promises: ps, - expectedSingleWritabilities: nil, - expectedVectorWritabilities: nil, - expectedFileWritabilities: [(12, 14)], - returns: [.processed(2)], - promiseStates: [[true, false]]) - XCTAssertEqual(.writtenCompletely, result) - - result = try assertExpectedWritability(pendingWritesManager: pwm, - promises: ps, - expectedSingleWritabilities: nil, - expectedVectorWritabilities: nil, - expectedFileWritabilities: nil, - returns: [], - promiseStates: [[true, false]]) - XCTAssertEqual(.writtenCompletely, result) - - pwm.markFlushCheckpoint() - - result = try assertExpectedWritability(pendingWritesManager: pwm, - promises: ps, - expectedSingleWritabilities: nil, - expectedVectorWritabilities: nil, - expectedFileWritabilities: [(0, 2), (1, 2)], - returns: [.processed(1), .processed(1)], - promiseStates: [[true, false], [true, true]]) - XCTAssertEqual(.writtenCompletely, result) - return [fh1, fh2] + let fh1 = FileHandle(descriptor: -1) + let fh2 = FileHandle(descriptor: -2) + let fr1 = FileRegion(fileHandle: fh1, readerIndex: 12, endIndex: 14) + let fr2 = FileRegion(fileHandle: fh2, readerIndex: 0, endIndex: 2) + defer { + // fake descriptors, so shouldn't be closed. + XCTAssertNoThrow(try fh1.takeDescriptorOwnership()) + XCTAssertNoThrow(try fh2.takeDescriptorOwnership()) } + _ = pwm.add(data: .fileRegion(fr1), promise: ps[0]) + pwm.markFlushCheckpoint() + _ = pwm.add(data: .fileRegion(fr2), promise: ps[1]) + + var result = try assertExpectedWritability(pendingWritesManager: pwm, + promises: ps, + expectedSingleWritabilities: nil, + expectedVectorWritabilities: nil, + expectedFileWritabilities: [(12, 14)], + returns: [.processed(2)], + promiseStates: [[true, false]]) + XCTAssertEqual(.writtenCompletely, result) + + result = try assertExpectedWritability(pendingWritesManager: pwm, + promises: ps, + expectedSingleWritabilities: nil, + expectedVectorWritabilities: nil, + expectedFileWritabilities: nil, + returns: [], + promiseStates: [[true, false]]) + XCTAssertEqual(.writtenCompletely, result) + + pwm.markFlushCheckpoint() + + result = try assertExpectedWritability(pendingWritesManager: pwm, + promises: ps, + expectedSingleWritabilities: nil, + expectedVectorWritabilities: nil, + expectedFileWritabilities: [(0, 2), (1, 2)], + returns: [.processed(1), .processed(1)], + promiseStates: [[true, false], [true, true]]) + XCTAssertEqual(.writtenCompletely, result) } } @@ -777,22 +785,24 @@ public class ChannelTests: XCTestCase { let el = EmbeddedEventLoop() try withPendingStreamWritesManager { pwm in let ps: [EventLoopPromise<()>] = (0..<1).map { (_: Int) in el.newPromise() } - try withPipe { (readFH, writeFH) in - let fr = FileRegion(fileHandle: writeFH, readerIndex: 99, endIndex: 99) - _ = pwm.add(data: .fileRegion(fr), promise: ps[0]) - pwm.markFlushCheckpoint() - let result = try assertExpectedWritability(pendingWritesManager: pwm, - promises: ps, - expectedSingleWritabilities: nil, - expectedVectorWritabilities: nil, - expectedFileWritabilities: [(99, 99)], - returns: [.processed(0)], - promiseStates: [[true]]) - XCTAssertEqual(.writtenCompletely, result) - return [readFH, writeFH] + let fh = FileHandle(descriptor: -1) + let fr = FileRegion(fileHandle: fh, readerIndex: 99, endIndex: 99) + defer { + // fake descriptor, so shouldn't be closed. + XCTAssertNoThrow(try fh.takeDescriptorOwnership()) } + _ = pwm.add(data: .fileRegion(fr), promise: ps[0]) + pwm.markFlushCheckpoint() + let result = try assertExpectedWritability(pendingWritesManager: pwm, + promises: ps, + expectedSingleWritabilities: nil, + expectedVectorWritabilities: nil, + expectedFileWritabilities: [(99, 99)], + returns: [.processed(0)], + promiseStates: [[true]]) + XCTAssertEqual(.writtenCompletely, result) } } @@ -804,45 +814,50 @@ public class ChannelTests: XCTestCase { try withPendingStreamWritesManager { pwm in let ps: [EventLoopPromise<()>] = (0..<5).map { (_: Int) in el.newPromise() } - try withSocketpair { (fh1, fh2) in - let fr1 = FileRegion(fileHandle: fh1, readerIndex: 99, endIndex: 99) - let fr2 = FileRegion(fileHandle: fh1, readerIndex: 0, endIndex: 10) - _ = pwm.add(data: .byteBuffer(buffer), promise: ps[0]) - _ = pwm.add(data: .byteBuffer(buffer), promise: ps[1]) - _ = pwm.add(data: .fileRegion(fr1), promise: ps[2]) - _ = pwm.add(data: .byteBuffer(buffer), promise: ps[3]) - _ = pwm.add(data: .fileRegion(fr2), promise: ps[4]) - - pwm.markFlushCheckpoint() - - var result = try assertExpectedWritability(pendingWritesManager: pwm, - promises: ps, - expectedSingleWritabilities: [4, 3, 2, 1], - expectedVectorWritabilities: [[4, 4]], - expectedFileWritabilities: [(99, 99), (0, 10), (3, 10), (6, 10)], - returns: [.processed(8), .processed(0), .processed(1), .processed(1), .processed(1), .processed(1), .wouldBlock(3), .processed(3), .wouldBlock(0)], - promiseStates: [[true, true, false, false, false], - [true, true, true, false, false], - [true, true, true, false, false], - [true, true, true, false, false], - [true, true, true, false, false], - [true, true, true, true, false], - [true, true, true, true, false], - [true, true, true, true, false], - [true, true, true, true, false]]) - XCTAssertEqual(.couldNotWriteEverything, result) - - result = try assertExpectedWritability(pendingWritesManager: pwm, - promises: ps, - expectedSingleWritabilities: nil, - expectedVectorWritabilities: nil, - expectedFileWritabilities: [(6, 10)], - returns: [.processed(4)], - promiseStates: [[true, true, true, true, true]]) - XCTAssertEqual(.writtenCompletely, result) - return [fh1, fh2] + let fh1 = FileHandle(descriptor: -1) + let fh2 = FileHandle(descriptor: -1) + let fr1 = FileRegion(fileHandle: fh1, readerIndex: 99, endIndex: 99) + let fr2 = FileRegion(fileHandle: fh1, readerIndex: 0, endIndex: 10) + defer { + // fake descriptors, so shouldn't be closed. + XCTAssertNoThrow(try fh1.takeDescriptorOwnership()) + XCTAssertNoThrow(try fh2.takeDescriptorOwnership()) } + + _ = pwm.add(data: .byteBuffer(buffer), promise: ps[0]) + _ = pwm.add(data: .byteBuffer(buffer), promise: ps[1]) + _ = pwm.add(data: .fileRegion(fr1), promise: ps[2]) + _ = pwm.add(data: .byteBuffer(buffer), promise: ps[3]) + _ = pwm.add(data: .fileRegion(fr2), promise: ps[4]) + + pwm.markFlushCheckpoint() + + var result = try assertExpectedWritability(pendingWritesManager: pwm, + promises: ps, + expectedSingleWritabilities: [4, 3, 2, 1], + expectedVectorWritabilities: [[4, 4]], + expectedFileWritabilities: [(99, 99), (0, 10), (3, 10), (6, 10)], + returns: [.processed(8), .processed(0), .processed(1), .processed(1), .processed(1), .processed(1), .wouldBlock(3), .processed(3), .wouldBlock(0)], + promiseStates: [[true, true, false, false, false], + [true, true, true, false, false], + [true, true, true, false, false], + [true, true, true, false, false], + [true, true, true, false, false], + [true, true, true, true, false], + [true, true, true, true, false], + [true, true, true, true, false], + [true, true, true, true, false]]) + XCTAssertEqual(.couldNotWriteEverything, result) + + result = try assertExpectedWritability(pendingWritesManager: pwm, + promises: ps, + expectedSingleWritabilities: nil, + expectedVectorWritabilities: nil, + expectedFileWritabilities: [(6, 10)], + returns: [.processed(4)], + promiseStates: [[true, true, true, true, true]]) + XCTAssertEqual(.writtenCompletely, result) } } @@ -875,6 +890,7 @@ public class ChannelTests: XCTestCase { _ = pwm.add(data: .byteBuffer(emptyBuffer), promise: ps[2]) + result = try assertExpectedWritability(pendingWritesManager: pwm, promises: ps, expectedSingleWritabilities: nil, @@ -897,6 +913,7 @@ public class ChannelTests: XCTestCase { } } + func testPendingWritesWorksWithManyEmptyWrites() throws { let el = EmbeddedEventLoop() let alloc = ByteBufferAllocator() @@ -999,22 +1016,25 @@ public class ChannelTests: XCTestCase { let el = EmbeddedEventLoop() try withPendingStreamWritesManager { pwm in let ps: [EventLoopPromise<()>] = (0..<1).map { (_: Int) in el.newPromise() } - try withPipe { (readFH, writeFH) in - let fr = FileRegion(fileHandle: writeFH, readerIndex: 0, endIndex: 8192) - _ = pwm.add(data: .fileRegion(fr), promise: ps[0]) - pwm.markFlushCheckpoint() - - let result = try assertExpectedWritability(pendingWritesManager: pwm, - promises: ps, - expectedSingleWritabilities: nil, - expectedVectorWritabilities: nil, - expectedFileWritabilities: [(0, 8192)], - returns: [.wouldBlock(8192)], - promiseStates: [[true]]) - XCTAssertEqual(.writtenCompletely, result) - return [readFH, writeFH] + let fh = FileHandle(descriptor: -1) + let fr = FileRegion(fileHandle: fh, readerIndex: 0, endIndex: 8192) + defer { + // fake descriptor, so shouldn't be closed. + XCTAssertNoThrow(try fh.takeDescriptorOwnership()) } + + _ = pwm.add(data: .fileRegion(fr), promise: ps[0]) + pwm.markFlushCheckpoint() + + let result = try assertExpectedWritability(pendingWritesManager: pwm, + promises: ps, + expectedSingleWritabilities: nil, + expectedVectorWritabilities: nil, + expectedFileWritabilities: [(0, 8192)], + returns: [.wouldBlock(8192)], + promiseStates: [[true]]) + XCTAssertEqual(.writtenCompletely, result) } } @@ -1130,7 +1150,7 @@ public class ChannelTests: XCTestCase { try server.bind(to: SocketAddress.newAddressResolving(host: "127.0.0.1", port: 0)) try server.listen() - class VerifyNoReadHandler: ChannelInboundHandler { + class VerifyNoReadHandler : ChannelInboundHandler { typealias InboundIn = ByteBuffer public func channelRead(ctx: ChannelHandlerContext, data: NIOAny) { @@ -1383,6 +1403,7 @@ public class ChannelTests: XCTestCase { let clientChannel = try ClientBootstrap(group: group) .connect(to: serverChannel.localAddress!).wait() + // Start shutting stuff down. try serverChannel.syncCloseAcceptingAlreadyClosed() try clientChannel.syncCloseAcceptingAlreadyClosed() diff --git a/Tests/NIOTests/TestUtils.swift b/Tests/NIOTests/TestUtils.swift index f60146cc3..444cf7bed 100644 --- a/Tests/NIOTests/TestUtils.swift +++ b/Tests/NIOTests/TestUtils.swift @@ -15,38 +15,17 @@ @testable import NIO import XCTest -func withPipe(_ body: (NIO.FileHandle, NIO.FileHandle) throws -> [NIO.FileHandle]) throws { +func withPipe(_ body: (NIO.FileHandle, NIO.FileHandle) -> [NIO.FileHandle]) throws { var fds: [Int32] = [-1, -1] fds.withUnsafeMutableBufferPointer { ptr in XCTAssertEqual(0, pipe(ptr.baseAddress!)) } let readFH = FileHandle(descriptor: fds[0]) let writeFH = FileHandle(descriptor: fds[1]) - - var toClose = [readFH, writeFH] - defer { - for fh in toClose { - XCTAssertNoThrow(try fh.close()) - } + let toClose = body(readFH, writeFH) + try toClose.forEach { fh in + XCTAssertNoThrow(try fh.close()) } - toClose = try body(readFH, writeFH) -} - -func withSocketpair(_ body: (NIO.FileHandle, NIO.FileHandle) throws -> [NIO.FileHandle]) throws { - var fds: [Int32] = [-1, -1] - fds.withUnsafeMutableBufferPointer { ptr in - XCTAssertEqual(0, socketpair(AF_UNIX, Posix.SOCK_STREAM, 0, ptr.baseAddress!)) - } - let readFH = FileHandle(descriptor: fds[0]) - let writeFH = FileHandle(descriptor: fds[1]) - - var toClose = [readFH, writeFH] - defer { - for fh in toClose { - XCTAssertNoThrow(try fh.close()) - } - } - toClose = try body(readFH, writeFH) } func withTemporaryFile(content: String? = nil, _ body: (NIO.FileHandle, String) throws -> T) rethrows -> T { @@ -102,7 +81,7 @@ internal extension Channel { } } -final class ByteCountingHandler: ChannelInboundHandler { +final class ByteCountingHandler : ChannelInboundHandler { typealias InboundIn = ByteBuffer private let numBytes: Int