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
[#4435] Always invoke the actual deregisteration later in the EventLoop. #4621
Conversation
@trustin @Scottmitch PTAL |
@trustin @Scottmitch PTAL... Fix was verified by @doom369 who reported the issue before. |
invokeLater(new OneTimeTask() { | ||
@Override | ||
public void run() { | ||
pipeline.fireChannelUnregistered(); |
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.
We are already in OneTimeTask
. Perhaps we could call pipeline.fireChannelUnregistered()
directly?
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.
@trustin I thought it was "delayed" for some reason in the past but could not really remember, so I thought I should just keep it delayed. But if you think it is fine to directly call the method after pipeline.fireChannelInactive() I'm happy to do so. WDYT ?
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.
We are already in invokeLater, so I don't think we need to do it again. i.e. direct call should be OK IMO.
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.
alright... let me update the PR and see if we get any issues :)
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.
+1
Motivation: As a user may call deregister() from within any method while doing processing in the ChannelPipeline, we need to ensure we do the actual deregister operation later. This is needed as for example, we may be in the ByteToMessageDecoder.callDecode(...) method and so still try to do processing in the old EventLoop while the user already registered the Channel to a new EventLoop. Without delay, the deregister operation this could lead to have a handler invoked by different EventLoop and so threads. Modifications: Ensure the actual deregister will be done later on and not directly when invoked. Result: Calling deregister() within ByteToMessageDecoder.decode(..) is safe.
cc1880a
to
8283e4d
Compare
lgtm ... good find! |
Motivation:
As a user may call deregister() from within any method while doing processing in the ChannelPipeline, we need to ensure we do the actual deregister operation later. This is needed as for example, we may be in the ByteToMessageDecoder.callDecode(...) method and so still try to do processing in the old EventLoop while the user already registered the Channel to a new EventLoop. Without delay, the deregister operation this could lead to have a handler invoked by different EventLoop and so threads.
Modifications:
Ensure the actual deregister will be done later on and not directly when invoked.
Result:
Calling deregister() within ByteToMessageDecoder.decode(..) is safe.