-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Return failed EventLoopFuture when getOption(...) / setOption(...) is… #198
Return failed EventLoopFuture when getOption(...) / setOption(...) is… #198
Conversation
c4e8b03
to
d01b92d
Compare
3e63e63
to
6c6fa7f
Compare
|
||
try assertSetGetOptionOnOpenAndClosed(channel: clientChannel, option: ChannelOptions.allowRemoteHalfClosure, value: true) | ||
try assertSetGetOptionOnOpenAndClosed(channel: serverChannel, option: ChannelOptions.backlog, value: 100) | ||
} |
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.
Can you do this for datagram channels too?
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.
done
6c6fa7f
to
4239216
Compare
@Lukasa always forget about |
ed36067
to
872f13f
Compare
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.
looks good but not the right error
Sources/NIO/SocketChannel.swift
Outdated
@@ -284,6 +284,10 @@ class BaseSocketChannel<T: BaseSocket>: SelectableChannel, ChannelCore { | |||
fileprivate func setOption0<T: ChannelOption>(option: T, value: T.OptionType) throws { | |||
assert(eventLoop.inEventLoop) | |||
|
|||
guard isOpen else { | |||
throw ChannelError.alreadyClosed |
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.
.alreadyClosed
is defined as only close
on already closed channel. This should be ioOnClosedChannel
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.
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.
@weissi fixed
… called on a closed Channel Motivation: We should return a failed EventLoopFuture when getOption(...) / setOption(...) is called on a closed Channel as otherwise it may not be safe to modify the Channel ioptions after its closed. Modifications: - Add guards that check if the Channel is still open and if not fail the operation. - Add testcase Result: Calling getOption(...) / setOption(...) on a closed Channel fails.
d803367
to
7e9824c
Compare
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!
Rebase and merge |
@swift-nio-bot test this please |
Motivation: Sometimes folks will want to print things about the HTTP2StreamChannel, and we should give them the things we can safely get. We also may want a shorter log for NIOHTTP2Handler as the standard description, with the wall of text available in the debug description. Modifications: - Conform HTTP2StreamChannel to CustomStringConvertible - Conform NIOHTTP2Handler to CustomDebugStringConvertible. Result: Even better debug info.
… called on a closed Channel
Motivation:
We should return a failed EventLoopFuture when getOption(...) / setOption(...) is called on a closed Channel as otherwise it may not be safe to modify the Channel ioptions after its closed.
Modifications:
Result:
Calling getOption(...) / setOption(...) on a closed Channel fails.