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

[5.1.z] Fix race in SingleProtocolEncoder [HZ-1008] #20994

Merged

Conversation

ufukyilmaz
Copy link
Contributor

SingleProtocolEncoder#signalProtocolVerified was called from the
decoder side, which runs on the input IO-thread, while
SingleProtocolEncoder#onWrite is called from the output IO-thread.
Since the shared state variables that these methods access are not
volatile, there was a data race. Also, isDecoderReceivedProtocol is
the first checked state variable in onWrite method, so we have to
update it last on the signal methods -> changed the order of updates to
satisfy this.

(cherry picked from commit 9e1ec99)

Backport: #20991

Checklist:

  • Labels (Team:, Type:, Source:, Module:) and Milestone set
  • Label Add to Release Notes or Not Release Notes content set
  • Request reviewers if possible

SingleProtocolEncoder#signalProtocolVerified was called from the
decoder side, which runs on the input IO-thread, while
SingleProtocolEncoder#onWrite is called from the output IO-thread.
Since the shared state variables that these methods access are not
volatile, there was a data race. Also, `isDecoderReceivedProtocol` is
the first checked state variable in onWrite method, so we have to
update it last on the signal methods -> changed the order of updates to
satisfy this.

(cherry picked from commit 9e1ec99)
@ufukyilmaz ufukyilmaz merged commit a84d80e into hazelcast:5.1.z Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants