swift-nio/Tests/NIOPosixTests
Cory Benfield 003fbadf51
Don't have channels stop reading on errors they tolerate. (#2408)
Motivation:

When an error is hit during a read loop, a channel is able to tolerate
that error without closing. This is done for a number of reasons, but
the most important one is accepting sockets for already-closed
connections, which can trigger all kinds of errors on the read path.

Unfortunately, there was an edge-case in the code for handling this
case. If one or more reads in the loop had succeeded before the error
was caught, the inner code would be expecting a call to readIfNeeded,
but the outer code wouldn't make it. This would lead to autoRead
channels being wedged open.

Modifications:

This patch extends the Syscall Abstraction Layer to add support for
server sockets. It adds two tests: one for the basic accept flow, and
then one for the case discussed above.

This patch also refactors the code in BaseSocketChannel.readable0 to
more clearly show the path through the error case. There were a number
of early returns and partial conditionals that led to us checking the
same condition in a number of places. This refactor makes it clearer
that it is possible to exit this code in the happy path, with a
tolerated error, which should be considered the same as reading
_something_.

Result:

Harder to wedge a channel open.
2023-04-20 11:09:02 +01:00
..
AcceptBackoffHandlerTest.swift Deprecate `NIOAtomics` in favor of `Atomics` (#2204) 2022-07-01 02:31:14 -07:00
BlockingIOThreadPoolTest.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
BootstrapTest.swift Add `NIOBSDSocket.ProtocolSubtype` (#2317) 2022-11-22 06:01:52 -08:00
ChannelNotificationTest.swift Use #fileID/#filePath instead of #file (#2306) 2022-11-03 16:43:13 +00:00
ChannelPipelineTest.swift Define `Array` element type explicitly to fix nightly CI (#2250) 2022-08-24 17:48:42 +01:00
ChannelTests.swift Pool buffers for ivecs and storage refs in the event loop. (#2358) 2023-02-07 13:48:26 +00:00
CodecTest.swift Use #fileID/#filePath instead of #file (#2306) 2022-11-03 16:43:13 +00:00
ControlMessageTests.swift Use #fileID/#filePath instead of #file (#2306) 2022-11-03 16:43:13 +00:00
DatagramChannelTests.swift Always populate utsname (#2391) 2023-03-14 09:37:10 -07:00
EchoServerClientTest.swift Deprecate `NIOAtomics` in favor of `Atomics` (#2204) 2022-07-01 02:31:14 -07:00
EventLoopFutureTest.swift Use #fileID/#filePath instead of #file (#2306) 2022-11-03 16:43:13 +00:00
EventLoopTest.swift Remove redundant availability guard (#2379) 2023-03-02 03:25:38 -08:00
FileRegionTest.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
GetAddrInfoResolverTest.swift NIOPosix: use internal enumeration for GAI resolver (#2177) 2022-06-09 08:21:24 +01:00
HappyEyeballsTest.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
IPv4Header.swift Fix non Darwin/Linux builds (#2328) 2022-12-02 08:48:54 -08:00
IdleStateHandlerTest.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
IntegerBitPackingTests.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
MulticastTest.swift Use #fileID/#filePath instead of #file (#2306) 2022-11-03 16:43:13 +00:00
NIOLoopBoundTests.swift OnLoopSendable: Sendable containers if on EventLoop (#2370) 2023-02-27 07:11:37 -08:00
NIOThreadPoolTest.swift mark syncShutdownGracefully noasync (#2381) 2023-03-02 06:20:23 -08:00
NonBlockingFileIOTest.swift cap read+pread POSIX read sizes at Int32.max (#2323) 2022-11-28 13:19:12 +00:00
PendingDatagramWritesManagerTests.swift Buffer pool for message headers and addresses. (#2378) 2023-03-10 16:06:02 +00:00
PipeChannelTest.swift Add `NIOBSDSocket.ProtocolSubtype` (#2317) 2022-11-22 06:01:52 -08:00
PooledRecvBufferAllocatorTests.swift Add a pooled recv buffer allocator (#2362) 2023-02-20 17:00:19 +00:00
RawSocketBootstrapTests.swift Add `RawSocketBootstrap` (#2320) 2022-12-01 15:35:04 +01:00
SALChannelTests.swift Don't have channels stop reading on errors they tolerate. (#2408) 2023-04-20 11:09:02 +01:00
SALEventLoopTests.swift Fix testSchedulingTaskOnSleepingLoopWakesUpOnce (#1992) 2021-11-25 10:04:25 +00:00
SelectorTest.swift Add `NIOBSDSocket.ProtocolSubtype` (#2317) 2022-11-22 06:01:52 -08:00
SocketAddressTest.swift Fix Nightly Build to work with new Swift versions (#2288) 2022-10-13 14:29:40 +01:00
SocketChannelTest.swift Don't have channels stop reading on errors they tolerate. (#2408) 2023-04-20 11:09:02 +01:00
SocketOptionProviderTest.swift Use #fileID/#filePath instead of #file (#2306) 2022-11-03 16:43:13 +00:00
StreamChannelsTest.swift Use #fileID/#filePath instead of #file (#2306) 2022-11-03 16:43:13 +00:00
SyscallAbstractionLayer.swift Don't have channels stop reading on errors they tolerate. (#2408) 2023-04-20 11:09:02 +01:00
SystemCallWrapperHelpers.swift Use #fileID/#filePath instead of #file (#2306) 2022-11-03 16:43:13 +00:00
SystemTest.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
TestUtils.swift Use #fileID/#filePath instead of #file (#2306) 2022-11-03 16:43:13 +00:00
ThreadTest.swift rename class Lock to struct NIOLock (#2266) 2022-09-21 07:36:42 -07:00
UniversalBootstrapSupportTest.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
XCTest+AsyncAwait.swift mark syncShutdownGracefully noasync (#2381) 2023-03-02 06:20:23 -08:00