Rebuild the channel when retrying testWriteBufferAtGSOSegmentCountLimit (#2383)

Motivation:

I (foolishly) didn't validate the test fix in #2382, instead I validated
that the original test passed with 61 segments (rather than 64). The
channel needs to be recreated first.

Modifications:

- Rebuild the channel before trying again if 64 segments is too many.

Result:

Test passes.
This commit is contained in:
George Barnett 2023-03-02 10:18:54 +00:00 committed by GitHub
parent ec6b8ed8c3
commit e2f161ba00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -1283,6 +1283,9 @@ class DatagramChannelTests: XCTestCase {
} catch let e as IOError where e.errnoCode == EINVAL {
// Some older kernel versions report EINVAL with 64 segments. Tolerate that
// failure and try again with a lower limit.
self.firstChannel = try self.buildChannel(group: self.group)
let didSet = self.firstChannel.setOption(ChannelOptions.datagramSegmentSize, value: CInt(segmentSize))
XCTAssertNoThrow(try didSet.wait())
segments = 61
try send(byteCount: segments * segmentSize)
}