Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

normanmaurer
Copy link
Member

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.

@normanmaurer
Copy link
Member Author

@trustin @Scottmitch PTAL

@normanmaurer normanmaurer self-assigned this Dec 23, 2015
@normanmaurer normanmaurer added this to the 4.0.34.Final milestone Dec 23, 2015
@normanmaurer
Copy link
Member Author

@trustin @Scottmitch PTAL... Fix was verified by @doom369 who reported the issue before.

invokeLater(new OneTimeTask() {
@Override
public void run() {
pipeline.fireChannelUnregistered();
Copy link
Member

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?

Copy link
Member Author

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 ?

Copy link
Member

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.

Copy link
Member Author

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 :)

Copy link
Member

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.
@normanmaurer
Copy link
Member Author

Cherry-picked into 4.0 (1516220) and 4.1 (d59bf84)

@normanmaurer normanmaurer deleted the invoke_later_deregister branch December 24, 2015 13:20
@Scottmitch
Copy link
Member

lgtm ... good find!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants