Commit Graph
33 Commits
Author SHA1 Message Date
Austin ffa6a871f7 Feature: Datagram Packet Info (#1888)
* Break out control message parsing by IP version

* Add shims for Darwin packet info

* Add shims for Linux packet info

* Add channel option for receiving datagram packet info

* Add NIOPacketInfo to AddressedEnvelope.Metadata

* Pipe up packet info channel option to receive path

* Add NIOPacketInfo info and fix backwards compatability

* Document packet info socket options

* Cleanup packet info control message parsing

* Add packet info and ECN combined tests

* Find real interface index during NIOPacketInfo tests

* Add PacketInfo tests to Linux tests
2021-07-08 11:04:53 +01:00
GuangGuangandCory Benfield a0c968a619 [swift-nio-ssl] fix compile error for swift-nio-ssl (#1734)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2021-01-25 08:49:26 +00:00
Peter AdamsandCory Benfield 4851816b65 Channel option to enable ECN reporting (#1506)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2020-06-02 16:36:17 +01:00
Johannes Weiss 438d6436fd fix accidental deprecation (#1470)
Motivation:

In one of the previous patches, we accidentally merged the deprecation
of `ChannelOptions.Types.SocketOption.init` which will break a lot of
NIO programs.

Modifications:

Undo the deprecation.

Result:

NIOTS builds without warnings.
2020-04-04 17:01:08 +01:00
Saleem AbdulrasoolandCory Benfield bcc180dab6 Add new BSDSocket namespace (#1461)
* NIO: Add new `BSDSocket` namespace

This starts the split of the POSIX/Linux/Darwin/BSD interfaces and the
BSD Socket interfaces in order to support Windows.  The constants on
Windows are not part of the C standard library and need to be explicitly
prefixed.  Use the import by name to avoid the `#if` conditions on the
wrapped versions.  This will allow us to cleanly cleave the dependency
on the underlying C library.

This change adds a `BSDSocket.OptionLevel` and `BSDSocket.Option` types
which allow us to get proper enumerations for these values and pipe them
throughout the NIO codebase.

* Apply suggestions from code review

Co-Authored-By: Cory Benfield <lukasa@apple.com>
2020-04-02 19:06:48 +01:00
Johannes Weiss d269ed5a26 don't use public extension (#1259)
Motivation:

`public extension`s are very dangerous because the make it so easy to
slip in public API by accident.

Modifications:

Don't use `public extension`.

Result:

Fewer chances to accidentally make stuff public.
2019-11-20 13:26:00 +00:00
Johannes Weiss 578e6d4bef don't use variable initialisation outside of init (#1235)
Motivation:

The Swift compiler actively tries to make our live hard and puts all
initialisations of variables that are initialised using the shorthand
syntax

    @usableFromInline var myVar: MyVarType = .init()

into a _non-inlinable_ function

     variable initialization expression of MyModule.MyType.myVar : MyVarType

This means that the following pattern

    public struct MyType {
        @usableFromInline var myVar: MyVarType = .init()

        @inlinable public init() {
        }
    }

leads to code for the `init` that looks like

    CALL variable_initialization_expression_...

instead of also inlining the the code for the variable initialiser.

Modifications:

Don't use `@usableFromInline var myVar: MyVarType = ...` anywhere,
instead put it explicitly into the @inlinable `init`s which makes
actually inlinable.
I even removed that syntax from places where it doesn't matter
(eg. non-@inlinable inits) for consistency and in case someone were to
make the init inlinable later.

Result:

Minor performance wins working around https://bugs.swift.org/browse/SR-11768
2019-11-12 15:11:32 +00:00
Johannes Weiss 93de65a217 cleanup some unnecessary #if os (#1199)
Motivation:

Certain `#if os` uses in SwiftNIO are unnecessary, they should be
removed.

Modifications:

Removed unnecessary `#if os` in SwiftNIO.

Result:

Nicer codebase.
2019-11-11 11:36:37 +00:00
Jake 58001dac80 namespace ChannelOptions types (#1148) (#1176)
Motivation:

ChannelOptions types like WriteBufferWaterMarkOption are global, public types. These types should be namespaced.

Modifications:

Moved global, public ChannelOptions types into ChannelOptions.Types enum. Created global, public typealiases with deprecation attributes which point to the namespaced types. Switched usage of these types in the codebase to use the namespaced versions.

Result:

Usage of the global, public versions of these types will cause deprecation warnings.
2019-10-22 12:32:45 -07:00
Johannes Weiss 7f20464df3 enable TCP_NODELAY by default (#1020)
Motivation:

Networking software like SwiftNIO that always has explicit flushes
usually does not benefit from having TCP_NODELAY switched off. The
benefits of having it turned on are usually quite substantial and yet we
forced our users for the longest time to enable it manually.

Quite a bit of engineering time has been lost finding performance
problems and it turns out switching TCP_NODELAY on solves them
magically.

Netty has made the switch to TCP_NODELAY on by default, SwiftNIO should
follow.

Modifications:

Enable TCP_NODELAY by default.

Result:

If the user forgot to enable TCP_NODELAY, their software should now be
faster.
2019-06-19 18:04:01 +01:00
Cory Benfield 8e32c53e4d Make ChannelOptions.Storage initializer public. (#988)
Motivation:

Structures that users can't create don't give them much value.

Modifications:

- Make the initializer public.
- Remove that godforsaken @testable import.

Result:

ChannelOptions.Storage sparks joy.
2019-05-01 14:09:35 +01:00
Cory Benfield b13bc66062 Support using recvmmsg to perform gathering reads. (#743)
Motivation:

Some DatagramChannels are extremely high-throughput. This can occur
when UDP is being used as an encapsulation for a transport protocol
(e.g. QUIC), or when a highly utilized service is being offered on a
single port (e.g. DNS).

In these cases, the syscall overhead of datagram reads is quite high
(one recvfrom call per datagram). It would be helpful to be able to
trade off some memory usage in order to reduce the cost of the syscalls
in this situation.

This patch adds support for transparently using the recvmmsg syscall
to achieve this kind of tradeoff.

Modifications:

- Added support to the DatagramChannel for issuing vector reads.
- Added new ChannelOption: DatagramVectorReadMessageCountOption
- Added UDP echo server example to exercise functionality.
- Tests

Result:

Able to achieve higher read throughput on supported systems.
2019-03-05 11:25:21 +00:00
Johannes Weiss f720de3ae0 make ChannelOptions.Storage public (#827)
Motivation:

To implement your own `Channel`s, you very likely need
`ChannelOptions.Storage`, so let's make it public.

Modifications:

- make ChannelOptions.Storage public

Result:

easier custom Channels
2019-02-21 19:43:23 +00:00
Johannes Weiss bf3b87cb4e simplify ChannelOptions (#828)
Motivation:

ChannelOptions used a too complicated mechanism for what they are.

Modifications:

- change the ChannelOptions to a much simpler mechanism
- rename the generic parameters from T to Option

Result:

code easier to read and understand
2019-02-19 18:31:26 +00:00
Johannes Weiss 877f0ebc12 require ChannelOptions to be Equatable (#823)
Motivation:

ChannelOptions should've always been Equatable and so far we've hacked
around them not being Equatable when we wanted to compare them.

Modifications:

make all ChannelOptions Equtable

Result:

- ChannelOption comparison actually works
- fixes #598
- make more ChannelOptions stuff inlinable to not regress allocations
2019-02-19 12:30:26 +00:00
Alex Reilly 6ca8c0e189 Documentation grammar fixes (#805) 2019-02-03 09:15:32 +00:00
George Barnett 6050c9c864 Fix documenation markup (#799)
Motivation:

Quick Documentation was not rendering some parameter documentation
correctly as it was over-indented.

Modifications:

Reduced indentation for over-indented parameters.

Result:

Quick Documentation renders correctly.
2019-02-01 15:34:59 +00:00
adamnemecek 0bbed6d72f * removed trailing whitespace (#52) 2018-03-02 15:40:52 +09:00
Norman Maurer c95051db78 Make WriteBufferWaterMark be a struct and validate low and high watermarks. (#21)
Motivation:

We used Range for WriteBufferWaterMark which did not do any validation of the low and high marks.

Modifications:

Make WriteBufferWaterMark a struct and validate low and high values

Result:

More correct impl for watermarks.
2018-02-23 09:52:30 +00:00
Johannes Weiss be1de1c433 simplify channel writes
Motivation:

Channel writes are a complex matter and it was even more
complex when `FileRegion` and `ByteBuffer` were completely
different kinds of objects. Now that they're more in line we can
simplify a lot of things.

Modifications:

Rewrote the inner layers of channel writes to make them more readable
and hopefully more correct.

Result:

hopefully fewer bugs.
2018-02-15 14:07:57 +00:00
Cory Benfield 2630d583cd Happy Eyeballs! 2018-02-02 17:26:51 +00:00
Norman Maurer 4d8cf1ff22 Add support for closing only the output / input side of the Channel. 2017-12-28 13:40:31 +01:00
Norman Maurer 8b9a31536e Allow to specify a connect timeout 2017-12-20 15:26:39 +01:00
Norman Maurer 8f1ad37edd Use camel case for ChannelOption factory values and add docs 2017-12-20 14:18:07 +01:00
Johannes Weiß e1b30f0a3d fix Channel writes 2017-12-05 17:08:42 +00:00
Johannes Weiss 1adb581f59 remove more Foundation imports 2017-10-10 16:25:43 +01:00
Norman Maurer d788dc6794 Ensure SocketOption uses the correct types on linux and macos by using typealias for each platform 2017-06-16 21:08:47 +02:00
Norman Maurer e3537e162b Port write buffer mark 2017-06-09 17:58:58 +02:00
Norman Maurer bff55bbb3d Port write spin configuration option from netty 2017-06-06 17:13:49 +02:00
Norman Maurer f933093a1e Introduce ServerSocketChannel which will accept SocketChannel instances. Now the ServerSocket and the Socket are both handled directly via the EventLoop and make use of the pipeline just like in Netty. 2017-05-23 14:53:21 +02:00
Norman Maurer d28a7573de Make swift-nio compile on linux as well 2017-05-19 20:34:12 +02:00
Johannes Weiß 8fb1162a7e fix missing constructor parameters 2017-05-19 00:03:06 +01:00
Norman Maurer 83d1f86efb Introduce ChannelOption and use it to set / get config values 2017-05-18 07:35:55 +02:00