From c312d93407974be781244b536119bdff2180cc20 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Wed, 1 Mar 2023 17:35:45 +0000 Subject: [PATCH] Rebuild the channel when retrying testWriteBufferAtGSOSegmentCountLimit 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. --- Tests/NIOPosixTests/DatagramChannelTests.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tests/NIOPosixTests/DatagramChannelTests.swift b/Tests/NIOPosixTests/DatagramChannelTests.swift index 9499796bee..11d939c639 100644 --- a/Tests/NIOPosixTests/DatagramChannelTests.swift +++ b/Tests/NIOPosixTests/DatagramChannelTests.swift @@ -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) }