Commit Graph
2945 Commits
Author SHA1 Message Date
David NadobaandCory Benfield 4574bdde82 Adopt Sendable in Codec.swift and SingleStepByteToMessageDecoder.swift (#2149)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-06-01 08:24:21 -07:00
David NadobaandCory Benfield 97a568ac61 Adopt Sendable in RecvByteBufferAllocator.swift (#2148)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-06-01 16:08:04 +01:00
David NadobaandCory Benfield 6f119c2995 Adopt Sendable in ChannelHandlers.swift (#2144)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-06-01 06:32:17 -07:00
David NadobaandCory Benfield 2f8d5408ae Adopt Sendable in ConvenienceOptionSupport.swift (#2145)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-06-01 05:58:16 -07:00
David NadobaandCory Benfield 6178126298 Adopt Sendable in NIOCloseOnErrorHandler.swift (#2146)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-06-01 05:28:43 -07:00
Saleem AbdulrasoolandCory Benfield 13a32273f7 NIOCore: adjust labels for inet_{ntop,pton} on Windows (#2141)
Update the callsites for the new labels for the BSDSocketAPI interfaces
that were not updated to reflect the new labels.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-06-01 05:05:50 -07:00
Cory Benfield 32f62a89d9 Fix flake AsyncEmbeddedEventLoopTest (#2147)
Motivation:

Flaky tests are really annoying.

Modifications:

- Stop assuming that the item is not immediately nil

Result:

Test now passes consistently.
2022-06-01 03:44:59 -07:00
Saleem Abdulrasool afbf7566d5 NIOCore: handle structural differences on Windows (#2140)
The `sockaddr_t` type on Windows is not laid out identically to the Unix
counterpart (due to pedantically correct reasons).  There exist an inner
union type for the reinterpretation of the storage which requires naming
the union type.
2022-05-31 16:07:32 -07:00
Saleem AbdulrasoolandCory Benfield 15aaf884b4 NIOCore: replace mode_t with CInt (#2132)
* NIOCore: replace `mode_t` with `CInt`

Windows does not have a `mode_t` type alias, instead using the
de-sugared `CInt` type.  De-sugar the instances to permit building on
Windows.

* Update Sources/NIOCore/FileHandle.swift

Co-authored-by: Cory Benfield <lukasa@apple.com>

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-05-31 14:15:47 -07:00
Saleem Abdulrasool 4d4c942c35 NIOCore: use errno accessor on Windows (#2139)
`errno` on Windows cannot be access as a raw name as it goes through a
"complex" macro for the TLS access.  Use the `_get_errno` helper instead
of accessing the `errno` through the macro for building on Windows.
2022-05-31 10:30:32 -07:00
Saleem Abdulrasool 8b3acb66b4 NIOCore: import INET{,6}_ADDRSTRLEN constants (#2138)
This imports the address string length constants from WinSock for
Windows.
2022-05-31 17:50:08 +01:00
Si Beaumont 9bf5075241 Add initial support for connected datagram sockets (#2084)
* socket: Make destinationPtr param optional in sendmsg(...)

Signed-off-by: Si Beaumont <beaumont@apple.com>

* pdwm: Fixup documentation: scalar writes use sendmsg, not sendto

Signed-off-by: Si Beaumont <beaumont@apple.com>

* pdwm: Make sockaddr pointer param optional in scalarWriteOperation

Signed-off-by: Si Beaumont <beaumont@apple.com>

* pdwm: Add isConnected property to PendingDatagramWritesState

Signed-off-by: Si Beaumont <beaumont@apple.com>

* pdwm: If socket is connected use NULL msg_name in sendmsg(2)

Signed-off-by: Si Beaumont <beaumont@apple.com>

* BaseSocketChannel: Support connect after bind

Signed-off-by: Si Beaumont <beaumont@apple.com>

* DatagramChannel: Implement connectSocket(to:)

Signed-off-by: Si Beaumont <beaumont@apple.com>

* bootstrap: Rename bind0(makeChannel:registerAndBind:) to withNewChannel(makeChannel:bringup:)

Signed-off-by: Si Beaumont <beaumont@apple.com>

* bootstrap: Add set of DatagramBootstrap.connect(...) APIs

Signed-off-by: Si Beaumont <beaumont@apple.com>

* test: Remove DatagramChannelTests.testConnectionFails

Signed-off-by: Si Beaumont <beaumont@apple.com>

* test: Add ConnectedDatagramChannelTests, inheriting from DatagramChannelTests

Signed-off-by: Si Beaumont <beaumont@apple.com>

* NIOUDPEchoClient: Use connected-mode UDP

Signed-off-by: Si Beaumont <beaumont@apple.com>

* soundness: Update copyright notice

Signed-off-by: Si Beaumont <beaumont@apple.com>

* fixup: cleanup bootstrap APIs

Signed-off-by: Si Beaumont <beaumont@apple.com>

* pdwm: Check address of pending write if connected and add test

Signed-off-by: Si Beaumont <beaumont@apple.com>

* Revert "pdwm: Check address of pending write if connected and add test"

This reverts commit a4ee0756d5.

* channel: Fail buffered writes on connect and validate writes when connected

Signed-off-by: Si Beaumont <beaumont@apple.com>

* Run soundness.sh to get linux tests generated

Signed-off-by: Si Beaumont <beaumont@apple.com>

* NIOUDPEchoClient: Connect socket to remote only if --connect is used

Signed-off-by: Si Beaumont <beaumont@apple.com>

* socket: Support ByteBuffer (without AddressedEnvelope) for DatagramChannel

Signed-off-by: Si Beaumont <beaumont@apple.com>

* test: Simplify some test code

Signed-off-by: Si Beaumont <beaumont@apple.com>

* pdwm: Factor out common, private add(_ pendingWrite:)

Signed-off-by: Si Beaumont <beaumont@apple.com>

* channel: Support AddressedEnvelope on connected socket for control messages

Signed-off-by: Si Beaumont <beaumont@apple.com>

* channel: Defer to common unwrapData for error handling

Signed-off-by: Si Beaumont <beaumont@apple.com>

* channel: Throw more specific (new) errors, instead of IOError

Signed-off-by: Si Beaumont <beaumont@apple.com>

* SocketChannelLifecycleManager: Add supportsReconnect boolean property, used in DatagramChannel

Signed-off-by: Si Beaumont <beaumont@apple.com>
2022-05-31 13:21:41 +01:00
Saleem Abdulrasool 083eba3652 NIOCore: correct typo in error namespace on Windows (#2133)
There was a missing `r` in the error type which caused a build failure
on Windows.  Correct the spelling for the error on Windows.
2022-05-31 10:52:07 +01:00
Saleem Abdulrasool e109615309 NIOCore: import WSAGetLastError, GetLastError (#2131)
We use these functions to report errors from WinSock.  This was likely
excluded accidentally from previous commits.
2022-05-30 11:00:34 -07:00
Saleem Abdulrasool 0f93ed145b NIOCore: adjust for label change on Windows (#2130)
`NIOBSDSocket.inet_pton` and `NIOBSDSocket.inet_ntop` altered the label
for the family parameter but failed to update the Windows path.  Adjust
the name accordingly.
2022-05-30 10:32:30 -07:00
Saleem Abdulrasool 78c97a3cda NIOCore: add missing import for IO (#2129)
Import `ucrt` for access to `strerror` on Windows.
2022-05-30 18:15:24 +01:00
Saleem Abdulrasool 5f8608bf0b _NIODataStructures: repair the build on Windows (#2128)
Import `ucrt` which is the MSVC C library to match the behaviour of the
other platforms.  This allows building `_NIODataStructures` on Windows.
2022-05-30 09:51:13 -07:00
Saleem AbdulrasoolandCory Benfield 78da9a1799 build: correct dependencies for NIOCore (#2127)
The `NIOCore` depends on the platform specific implementation but the
dependency for the Windows platform content was missing.  Adjust this
to repair the build graph for Windows.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-05-30 09:33:04 -07:00
Si BeaumontandCory Benfield b7308b1cd0 DatagramChannelTests: Handle receiving datagrams out-of-order in ECN tests (#2123)
* DatagramChannelTests: Handle receiving datagrams out-of-order in ECN tests

Signed-off-by: Si Beaumont <beaumont@apple.com>

* fixup: Simplify calls to write and read integer in payload

Signed-off-by: Si Beaumont <beaumont@apple.com>

* fixup: Iterate through expected reads, not actual reads

Signed-off-by: Si Beaumont <beaumont@apple.com>

* fixup: Order reads by seq payload and use array equality

* Update Tests/NIOPosixTests/DatagramChannelTests.swift

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-05-30 03:51:52 -07:00
David NadobaandCory Benfield e16a340c57 Adopt Sendable for EventLoopFuture and EventLoopPromise (#2107)
* Adopt `Sendable` for `EventLoopFuture` and `EventLoopPromise`

* use internal typealias to deduplicate method bodies

* fix `Sendable` warnings for nightly toolchains

* fix compliation for Swift 5.5 & 5.6

* Adopt `Sendable` only in Swift 5.7+

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-05-30 11:35:23 +01:00
David Nadoba 94969e7280 Adopt Sendable in EventLoop.swift (#2101)
* Adopt `Sendable` in `EventLoop.swift`

* only adopt `Sendable` in Swift 5.6+

* add `@Sendable` only for Swift 5.7

* fix swift 5.5

* use internal typealias to deduplicate method bodies
2022-05-30 10:41:18 +01:00
Si Beaumont 8b25ba9761 readme: Fix API docs link following NIO core refactoring (#2126)
Signed-off-by: Si Beaumont <beaumont@apple.com>
2022-05-30 01:03:30 -07:00
Si Beaumont 92d20d92b0 wip: Use clock_gettime for NIODeadline.now() (#2119)
* wip: Use clock_gettime for NIODeadline.now()

Signed-off-by: Si Beaumont <beaumont@apple.com>

* fixup: Add #if os(Linux) for clock_gettime use

* fixup: Add doc comments

Signed-off-by: Si Beaumont <beaumont@apple.com>
2022-05-19 09:28:31 +01:00
Si Beaumont 9294f8da3b NIOPerformanceTester: Increase operations used in lock benchmarks from 1M to 10M (#2121) 2022-05-18 10:53:51 +01:00
David Nadoba 3dcb0f5e9b Introduce internal UnsafeTransfer type (#2115)
Motivation:

Soon we will need to silence some `Sendable` warnings. 
The recommended way is to use a wrapper type that is unconditionally 
`Sendable`. 

https://github.com/apple/swift-evolution/blob/main/proposals/0302-concurrent-value-and-concurrent-closures.md#adaptor-types-for-legacy-codebases

Modifications:

- add internal `UnsafeTransfer` type

Result:

We can silence `Sendable` warnings and errors by using `UnsafeTransfer` to pass non-`Sendable` values around.
2022-05-17 08:58:11 +01:00
Si Beaumont 771257cc23 NIOPerformanceTester: Add DeadlineNowBenchmark for NIODeadline.now() (#2117)
* NIOPerformanceTester: Add DeadlineNowBenchmark for NIODeadline.now()

Signed-off-by: Si Beaumont <beaumont@apple.com>

* fixup: Return counter from benchmark

Signed-off-by: Si Beaumont <beaumont@apple.com>
2022-05-16 19:21:31 +01:00
David Nadoba 391ab9122c Reduce the alloc limits for main (#2118)
The nightly builds have improved, so the alloc limits can drop slightly
2022-05-16 09:56:45 -07:00
David Nadoba 14ffe73e1b Reduce the alloc limits of 1000_tcpconnections for main (#2116)
The nightly builds have improved, so the alloc limits can drop slightly
2022-05-16 02:48:31 -07:00
David Nadoba 4fb931da3f Deprecate unsafe ChannelPipeline.context(handler:) methods (#2109)
`ChannelHandlerContext` is not `Sendable` and can not safly be used outside of its  EventLoop.
2022-05-13 12:39:03 +02:00
David Nadoba bd4366b32c Adopt Sendable for Channel (#2104) 2022-05-11 09:59:51 +01:00
David NadobaandCory Benfield 291143d83d Adopt Sendable for NIONetworkDevice (#2103)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-05-10 09:01:56 -07:00
David Nadoba 54aadfaf38 Adopt Sendable for NIOFileHandle.Mode and NIOFileHandle.Flags (#2102)
`NIOFileHandler` and `FileRegion` are not thread-safe and can not conform to `Sendable`
2022-05-10 16:42:19 +01:00
David Nadoba 45b90b9506 Adopt Sendable for SocketOptionProvider (#2100) 2022-05-10 09:19:54 +01:00
David Nadoba dbbdabb24a Adopt Sendable for Types in ChannelOptions Namespace (#2098)
* Adopt `Sendable` for Types in `ChannelOptions` Namespace

* mark `ChannelOption` as @preconcurrecy Sendable

and introduce `NIOPreconcurrencySendable`
2022-05-09 15:31:36 +01:00
David Nadoba 4fb6bf135b Adopt Sendable for CircularBuffer, MarkedCircularBuffer and types in NIOBSDSocket namespace (#2097)
* Adopt `Sendable` for types in `BSDSocket` namespace

* Adopt `Sendable` for `CircularBuffer` and `MarkedCircularBuffer`

and also `Endianness`

* move `NIOSendable` into its own file and copy it over to syscall integration tests
2022-05-06 12:34:31 +01:00
David NadobaandCory Benfield 788ade1cc3 Adopt Sendable for SocketAddress, AddressedEnvelope and friends (#2096)
* Box: Sendable

* SocketAdress: Sendable and friends

* AddressEnvelop: Sendable and friends

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-05-04 09:33:57 -07:00
Cory BenfieldandFranz Busch ad8500b3d0 Define AsyncEmbeddedEventLoop (#2083)
Motivation

The rise of Swift concurrency has meant that a number of our APIs need
to be recontextualised as async/await capable. While generally this is a
straightforward task, any time those APIs were tested using
EmbeddedChannel we have a testing issue. Swift Concurrency requires the
use of its own cooperative thread pool, which is completely incapable of
safely interoperating with EmbeddedChannel and EmbeddedEventLoop. This
is becuase those two types "embed" into the current thread and are not
thread-safe, but our concurrency-focused APIs want to enable users to
use them from any Task.

To that end we need to develop new types that serve the needs of
EmbeddedChannel and EmbeddedEventLoop (control over I/O and task
scheduling) while remaining fully thread-safe. This is the first of a
series of patches that adds this functionality, starting with the
AsyncEmbeddedEventLoop.

Modifications

- Define AsyncEmbeddedEventLoop

Result

A required building block for AsyncEmbeddedChannel exists.

Co-authored-by: Franz Busch <privat@franz-busch.de>
2022-05-04 09:03:03 -07:00
Si BeaumontandCory Benfield cd11cf8202 Move tests of NIOCore types from NIOPosixTests to NIOCoreTests (#2093)
* Move tests of NIOCore types from NIOPosixTests to NIOCoreTests

* fixup: LinuxTest

Signed-off-by: Si Beaumont <beaumont@apple.com>

* fixup: Port some test utils to not use NIOPosix

Signed-off-by: Si Beaumont <beaumont@apple.com>

* fixup: No swift-system, duh

Signed-off-by: Si Beaumont <beaumont@apple.com>

* fixup: read-write for temporary file in test helper

Signed-off-by: Si Beaumont <beaumont@apple.com>

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-05-04 08:14:18 -07:00
Cory Benfield b1b44ca67b Reduce the alloc limits for main (#2095)
The nightly builds have improved, so the alloc limits can drop slightly
2022-05-04 15:49:40 +01:00
George Barnett 1a4028a96b Remove build_podspec.sh (#2094)
Motivation:

We no longer support Cocoapods.

Modifications:

- Remove build_podspec.sh and associated scripts

Result:

Less unused code.
2022-05-04 03:19:09 -07:00
David Nadoba 5868651f58 Adopt Sendable for ByteBuffer and friends (#2092)
- `ByteBuffer`
- `ByteBufferView`
- `_ByteBufferSlice`
- `_UInt24`
- `_UInt56`
2022-05-03 08:55:23 -07:00
David Nadoba d47e96ad87 Adopt sendable in _NIODataStructures (#2091) 2022-05-03 05:12:37 -07:00
David Evans 71f60c4fd5 Make NIOConcurrencyHelpers Sendable (#2090)
Stop Sendable related warnings when using types defined inside NIOConcurrencyHelpers. All the code should actually already be thread safe, so no changes needed other than labelling some classes as either Sendable or @unchecked Sendable.
2022-04-28 17:04:46 +01:00
Si Beaumont 124119f0bb BaseSocket: Remove dead code in BaseSocket.bind(to:) (#2086)
Signed-off-by: Si Beaumont <beaumont@apple.com>
2.40.0
2022-04-22 09:42:09 -07:00
Fabian Fett 1fbb42b245 Fix warnings, that appeared after requiring Swift 5.4 (#2085) 2022-04-21 09:12:01 -07:00
Si BeaumontandCory Benfield 684c09315f Use unbuffered IO for stdout in NIOPerformanceTester (#2072)
* Use unbuffered IO for stdout in NIOPerformanceTester

Signed-off-by: Si Beaumont <beaumont@apple.com>

* CRASH PERF TESTS: Up task count to 1M to test logging change

* Revert "CRASH PERF TESTS: Up task count to 1M to test logging change"

This reverts commit d8fa50eb15.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-04-20 13:16:14 -07:00
George Barnett f32314f82f Script to list transitive dependencies (#2082)
Motivation:

Cocoapods appears to have a different idea of the dependency graph to
SPM which has led to a handful of build failures (e.g.
https://github.com/apple/swift-nio/issues/2073).

This appears to have originated when we dropped the explicit dependency
on `CNIOAtomics` from `NIO` (https://github.com/apple/swift-nio/pull/1719).

We can work around this by listing all transitive dependencies as
requirements in the generated podspecs.

Modifications:

- Add a script to list transitive dependencies for a given module.
- Fix a bug in build_podspecs.sh which did a `pod repo update` even if
  the pods were not being uploaded.
- Update build_podspecs.sh to use transitive dependencies.
- Use Python3 in 'dev/stackdiff-dtrace.py' and update soundness.sh

Result:

Podspecs should include all transitive dependencies.
2022-04-20 14:39:43 +01:00
Fabian FettandCory Benfield dc8a317a24 Drop support for Swift 5.2 and 5.3 (#2080)
* Drop support for 5.2 and 5.3

As outlined in a [Swift forums post in November ’21](https://forums.swift.org/t/swiftnio-swift-version-support/53232), SwiftNIO will only support the latest non-patch Swift release and the 2 immediately prior non-patch versions.

In this commit we drop support for Swift 5.2 and 5.3. We update CI for Swift 5.4 to run on bionic instead of focal to ensure that we still test bionic.

* Added Versions paragraph to Security document

* Apply suggestions from code review

Co-authored-by: Cory Benfield <lukasa@apple.com>

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-04-20 11:48:41 +01:00
Johannes Weiss ef8430d620 update contributors (#2077) 2022-04-19 16:40:26 +01:00
Johannes Weiss 5ec860a3c8 http_parser uses "main" as the main branch (#2078) 2022-04-13 22:00:29 +01:00