diff --git a/Sources/NIO/Channel.swift b/Sources/NIO/Channel.swift index 837a13727..42cc4df0b 100644 --- a/Sources/NIO/Channel.swift +++ b/Sources/NIO/Channel.swift @@ -410,7 +410,7 @@ private struct PendingWritesState { private func triggerSingleWrite(singleWriteOperation: (UnsafeRawBufferPointer) throws -> IOResult, fileWriteOperation: (Int32, Int, Int) throws -> IOResult) rethrows -> WriteResult { if self.state.isFlushPending && !self.state.isEmpty { - for _ in 0...writeSpinCount { + for _ in 0..) throws -> IOResult) throws -> WriteResult { assert(self.state.isFlushPending && !self.state.isEmpty, "vector write called in state flush pending: \(self.state.isFlushPending), empty: \(self.state.isEmpty)") - for _ in 0...writeSpinCount { + for _ in 0..(repeating: 0xff, count: numberOfBytes)) let ps: [EventLoopPromise<()>] = (0..<1).map { _ in el.newPromise() } @@ -541,7 +541,7 @@ public class ChannelTests: XCTestCase { var buffer = alloc.buffer(capacity: 12) withPendingWritesManager { pwm in - let numberOfBytes = Int(pwm.writeSpinCount + 1 /* because we spin 1 + spin count */ + 1 /* so one byte remains at the end */) + let numberOfBytes = Int(pwm.writeSpinCount + 1 /* so one byte remains at the end */) buffer.clear() buffer.write(bytes: [0xff] as [UInt8]) let ps: [EventLoopPromise<()>] = (0..