-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract the NWConnection code into StateManagedNWConnectionChannel #174
Extract the NWConnection code into StateManagedNWConnectionChannel #174
Conversation
In hindsight, I do think it's valuable to also add a common implementation for listener channels, and add that to UDP right away as well. Give me a bit more time. EDIT: It'll be a second PR. |
Tests/NIOTransportServicesTests/NIOFilterEmptyWritesHandlerTests.swift
Outdated
Show resolved
Hide resolved
Sources/NIOTransportServices/StateManagedNWConnectionChannel.swift
Outdated
Show resolved
Hide resolved
Updated now! I removed the lock from |
…the underscores to the addressCache properties
Updated @Lukasa , thanks for the quick reviews thus far. And have a nice weekend for now :) |
Ping @Lukasa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok great, this LGTM.
@swift-server-bot add to allowlist |
To try to get this landed I took the liberty of just fixing the soundness violation myself. |
Extract the NWConnection code into StateManagedNWConnectionChannel
Motivation:
When implementing #68, a lot of code ended up being identical between TCP and UDP. This PR paves the way to adding UDP, with very little overhead code. It moves the code that is used to represent NWConnection as a Channel into its own protocol, that can then be applied to both TCP and UDP implementations.
Modifications:
StateManagedNWConnectionChannel
that has all the logic for handling a NWConnection as a NIO.Channel.NWOptionsProtocol
that can read and write socket options. This is applied toNWProtocolTCP.Option
StateManagedNWConnectionChannel
handles the common denominators between TCP and the future UDP implementaitonNWConnectionSubstate
that can handle changes in the ChannelState.Result:
This makes implementing UDP much simpler, and without redundant code.