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

fix(network): fix inconsistent typed value issue in DelegatePacketProxy #35

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

jyyi1
Copy link
Contributor

@jyyi1 jyyi1 commented Aug 3, 2023

atomic.Value doesn't accept values with different struct types (even if you cast the value to the same interface). So I use atomic.Pointer[] instead.

Example: https://go.dev/play/p/eNop7iJ3wyO

@jyyi1 jyyi1 requested a review from fortuna August 3, 2023 01:14
return &dp, nil
}

// NewSession implements PacketProxy.NewSession, and it will forward the call to the underlying PacketProxy.
func (p *delegatePacketProxy) NewSession(respWriter PacketResponseReceiver) (PacketRequestSender, error) {
return p.proxy.Load().(PacketProxy).NewSession(respWriter)
return (*p.proxy.Load()).NewSession(respWriter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice that we don't need to cast anymore!

@jyyi1 jyyi1 merged commit 685046f into main Aug 7, 2023
4 checks passed
@jyyi1 jyyi1 deleted the junyi/fix-delegate-packetproxy-atomic-type branch August 7, 2023 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants