swift-nio/Sources/NIOPosix
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
..
BSDSocketAPICommon.swift Add `RawSocketBootstrap` (#2320) 2022-12-01 15:35:04 +01:00
BSDSocketAPIPosix.swift Add support for UDP_GRO (#2385) 2023-03-06 07:12:09 -08:00
BSDSocketAPIWindows.swift Add support for UDP_GRO (#2385) 2023-03-06 07:12:09 -08:00
BaseSocket.swift Fix an upcoming compiler warning on implicit raw pointer casts. (#2377) 2023-02-28 00:23:36 -08:00
BaseSocketChannel+SocketOptionProvider.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
BaseSocketChannel.swift Don't have channels stop reading on errors they tolerate. (#2408) 2023-04-20 11:09:02 +01:00
BaseStreamSocketChannel.swift Add a pooled recv buffer allocator (#2362) 2023-02-20 17:00:19 +00:00
Bootstrap.swift Drop Swift 5.5 (#2406) 2023-04-17 08:40:35 +01:00
ControlMessage.swift NIOPosix: add missing `CNIOWindows` import (#2184) 2022-06-13 05:53:07 -07:00
DatagramVectorReadManager.swift NIOPosix: adjust precondition for Windows (#2183) 2022-06-10 09:14:27 -07:00
FileDescriptor.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
GetaddrinfoResolver.swift NIOPosix: use internal enumeration for GAI resolver (#2177) 2022-06-09 08:21:24 +01:00
HappyEyeballs.swift Replace `NIOSendable` with `Sendable` (#2291) 2022-10-13 15:56:27 +01:00
IO.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
IntegerBitPacking.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
IntegerTypes.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
Linux.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
LinuxCPUSet.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
LinuxUring.swift Enable io_uring builds with newer liburing (#2006) 2021-12-09 09:19:12 +00:00
MultiThreadedEventLoopGroup.swift Don't retain a task when all we want is a time (#2373) 2023-02-20 07:27:58 -08:00
NIOThreadPool.swift mark syncShutdownGracefully noasync (#2381) 2023-03-02 06:20:23 -08:00
NonBlockingFileIO.swift cap read+pread POSIX read sizes at Int32.max (#2323) 2022-11-28 13:19:12 +00:00
PendingDatagramWritesManager.swift Buffer pool for message headers and addresses. (#2378) 2023-03-10 16:06:02 +00:00
PendingWritesManager.swift Make PooledBuffer safer. (#2363) 2023-02-08 07:59:17 +00:00
PipeChannel.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
PipePair.swift Add initial support for connected datagram sockets (#2084) 2022-05-31 13:21:41 +01:00
PointerHelpers.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
Pool.swift Buffer pool for message headers and addresses. (#2378) 2023-03-10 16:06:02 +00:00
PooledRecvBufferAllocator.swift Add a pooled recv buffer allocator (#2362) 2023-02-20 17:00:19 +00:00
RawSocketBootstrap.swift Drop Swift 5.5 (#2406) 2023-04-17 08:40:35 +01:00
Resolver.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
Selectable.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
SelectableChannel.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
SelectableEventLoop.swift Buffer pool for message headers and addresses. (#2378) 2023-03-10 16:06:02 +00:00
SelectorEpoll.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
SelectorGeneric.swift rename class Lock to struct NIOLock (#2266) 2022-09-21 07:36:42 -07:00
SelectorKqueue.swift Add safer abstraction for kqueue filter set. (#1951) 2021-09-06 14:59:30 +01:00
SelectorUring.swift Fixed some typos (#2051) 2022-02-22 01:37:47 -08:00
ServerSocket.swift Close accepted FDs if we fail to create Socket (#2407) 2023-04-19 18:26:55 +01:00
Socket.swift Add support for UDP_GRO (#2385) 2023-03-06 07:12:09 -08:00
SocketChannel.swift Buffer pool for message headers and addresses. (#2378) 2023-03-10 16:06:02 +00:00
SocketProtocols.swift Add support for UDP_SEGMENT (#2372) 2023-02-27 13:18:58 +00:00
System.swift Add `NIOBSDSocket.ProtocolSubtype` (#2317) 2022-11-22 06:01:52 -08:00
Thread.swift Remove `#if compiler(>=5.5)` (#2292) 2022-10-13 07:17:46 -07:00
ThreadPosix.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
ThreadWindows.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00
Utilities.swift Move NIO to NIOPosix, make NIO a shell. (#1936) 2021-08-16 16:50:40 +01:00