-
Notifications
You must be signed in to change notification settings - Fork 721
Embedded: getOption(ChannelOptions.allowRemoteHalfClosure) should not fatalError
#2429
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
Embedded: getOption(ChannelOptions.allowRemoteHalfClosure) should not fatalError
#2429
Conversation
Sources/NIOEmbedded/Embedded.swift
Outdated
| internal func getOptionSync<Option: ChannelOption>(_ option: Option) -> Option.Value { | ||
| if option is ChannelOptions.Types.AutoReadOption { | ||
| if option is ChannelOptions.Types.AutoReadOption | ||
| || option is ChannelOptions.Types.AllowRemoteHalfClosureOption { |
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.
I know I gave you this advice, so this is really my fault, but I no longer think this behaviour is quite right. 😁
I think we should allow the user of EmbeddedChannel to have a public var that they can set which provides the value of AllowRemoteHalfClosureOption. That lets tests configure whether the behaviour should be supported or not. This also lets us support setOption for this option.
Relatedly, the default value should be false.
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.
That makes sense 😄! I have pushed the new changes (amended to my old commit)!
53ae2d9 to
be337ff
Compare
Lukasa
left a comment
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.
Great, this looks really good. Can I ask you to make the same enhancement to AsyncTestingChannel as well? That will keep the two interfaces in step.
Motivation: In `swift-nio-ssl`, I am currently working on allowing half-closures which relies on querying the underlying channel if `ChannelOptions.Types.AllowRemoteHalfClosureOption` is enabled. As a lot of `swift-nio-ssl`'s tests rely on `EmbeddedChannel` and it did not support this option, a lot of the tests failed. Modifications: * add a `public var allowRemoteHalfClosure` to `EmbeddedChannel` * enable setting/getting `ChannelOptions.Types.AllowRemoteHalfClosureOption` in `EmbeddedChannel` (only modifies the `allowRemoteHalfClosure` variable * add test for new behaviour
Motivation: `AsyncTestingChannel` interface should be in step with `EmbeddedChannel` interface. Therefore also add support for the `AllowRemoteHalfClosureOption` Modifications: * add a `public var allowRemoteHalfClosure` to `AsyncTestingChannel` * enable setting/getting `ChannelOptions.Types.AllowRemoteHalfClosureOption` in `AsyncTestingChannel` (only modifies the `allowRemoteHalfClosure` variable * add tests for new behaviour
be337ff to
7560113
Compare
| public var isActive: Bool { return channelcore.isActive } | ||
|
|
||
| /// - see: `ChannelOptions.Types.AllowRemoteHalfClosureOption` | ||
| public var allowRemoteHalfClosure: Bool = false |
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.
This needs synchronization around it. Can you follow the pattern we used for isActive?
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.
Thanks for pointing that out! Have moved allowRemoteClosure to EmbeddedChannelCore now!
Modifications: * add `ManagedAtomic` property `_allowRemoteHalfClosure` to `EmbeddedChannelCore` * make sure that access to `allowRemoteHalfClosure` from `AsyncTestingChannel` and `EmbeddedChannel` is synchronized by accessing underlying atomic value in `channelcore`
Lukasa
left a comment
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.
Fantastic!
|
@swift-server-bot add to allowlist |
|
Can you update the allocation limits? |
Allocations regressed due to our use of EmbeddedChannel, which now uses a new atomic since apple/swift-nio#2429. We can update the limits accordingly.
Allocations regressed due to our use of EmbeddedChannel, which now uses a new atomic since apple/swift-nio#2429. We can update the limits accordingly.
Allocations regressed due to our use of EmbeddedChannel, which now uses a new atomic since apple/swift-nio#2429. We can update the limits accordingly.
Allocations regressed due to our use of EmbeddedChannel, which now uses a new atomic since apple/swift-nio#2429. We can update the limits accordingly.
Motivation
In
swift-nio-ssl, I am currently working on allowing half-closures which rely on querying the underlying channel ifChannelOptions.Types.AllowRemoteHalfClosureOptionis enabled. As a lot ofswift-nio-ssl's tests rely onEmbeddedChannel, which did not support this option, they failed failed due to afatalError.Modifications
public var allowRemoteHalfClosuretoEmbeddedChannelChannelOptions.Types.AllowRemoteHalfClosureOptioninEmbeddedChannel(only modifies theallowRemoteHalfClosurevariable