-
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
Ensure localAddress / remoteAddress are still accessible in channelIn… #346
Ensure localAddress / remoteAddress are still accessible in channelIn… #346
Conversation
@ldewailly PTAL as well |
Sources/NIO/ChannelPipeline.swift
Outdated
do { | ||
// Fast-path access to the remoteAddress. | ||
return try self.channel._unsafe.remoteAddress0() | ||
} catch let err as ChannelError where err == .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.
No need for this verbose syntax, just do catch ChannelError.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.
TIL
Sources/NIO/ChannelPipeline.swift
Outdated
do { | ||
// Fast-path access to the localAddress. | ||
return try self.channel._unsafe.localAddress0() | ||
} catch let err as ChannelError where err == .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.
Same here.
8cf0ced
to
f960e25
Compare
@Lukasa addressed |
…active / handlerRemoved Motivation: Often its useful to be still be able to access the local / remote address during channelInactive / handlerRemoved callbacks to for example log it. We should ensure its still accessible during it. Modifications: - Fallback to slow-path in ChannelHandlerContext.localAddress0 / remoteAddress0 if fast-path fails to try accessing the address via the cache. - Clear cached addresses after all callbacks are run. - Add unit test. Result: Be able to access addresses while handlers are notified.
f960e25
to
d655f04
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.
lgtm
…active / handlerRemoved
Motivation:
Often its useful to be still be able to access the local / remote address during channelInactive / handlerRemoved callbacks to for example log it. We should ensure its still accessible during it.
Modifications:
Result:
Be able to access addresses while handlers are notified.