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

Ensuring Goroutine Safety in DTLS Connection Handshake Completion #667

Open
jkralik opened this issue Aug 6, 2024 · 0 comments
Open

Ensuring Goroutine Safety in DTLS Connection Handshake Completion #667

jkralik opened this issue Aug 6, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jkralik
Copy link
Contributor

jkralik commented Aug 6, 2024

This code is not goroutine(thread) safe:
https://github.com/pion/dtls/blob/e20b1620594ce408a20636f455b00ed9a3d69512/conn.go#L1031C3-L1034C4

Because the check c.isHandshakeCompletedSuccessfully is not in the same critical section as c.setHandshakeCompletedSuccessfully(), to fix the issue, c.setHandshakeCompletedSuccessfully() will return a boolean. Internally, it will use CompareAndSwap instead of Store. If it swaps, it returns true and the done channel can be closed.

@jkralik jkralik added the bug Something isn't working label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant