fix write spinning (should be max writeSpinCount writes)

This commit is contained in:
Johannes Weiss committed 2017-12-12 14:14:10 +00:00
1 parent 4e188e74b3
commit e4ef4c19f7
2 files changed
+4 -4

No files matched your search

+2 -2
View File
@@ -410,7 +410,7 @@ private struct PendingWritesState {
private func triggerSingleWrite(singleWriteOperation: (UnsafeRawBufferPointer) throws -> IOResult<Int>,
fileWriteOperation: (Int32, Int, Int) throws -> IOResult<Int>) rethrows -> WriteResult {
if self.state.isFlushPending && !self.state.isEmpty {
for _ in 0...writeSpinCount {
for _ in 0..<writeSpinCount {
assert(!closed,
"Channel got closed during the spinning of a single write operation which should be impossible as we don't call out")
let pending = self.state[0]
@@ -444,7 +444,7 @@ private struct PendingWritesState {
private func triggerVectorWrite(vectorWriteOperation: (UnsafeBufferPointer<IOVector>) throws -> IOResult<Int>) 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..<writeSpinCount {
if closed {
return .closed
}
+2 -2
View File
@@ -503,7 +503,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: Array<UInt8>(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..<numberOfBytes).map { _ in