Skip to content

Replace conn.session with atomic.Pointer#44

Merged
arashpayan merged 2 commits intomainfrom
use_session_atomic
Mar 17, 2026
Merged

Replace conn.session with atomic.Pointer#44
arashpayan merged 2 commits intomainfrom
use_session_atomic

Conversation

@rakitzis
Copy link
Copy Markdown
Collaborator

The session variable in conn was accessed after _useSession was
polled via an atomic.Load(), but this obscured the safety of
loads and stores of conn.session.

This change introduces an atomic.Pointer for clarity, and also
guarantees that if conn.session is accessed without first verifying
useSession that conn will not be accessed unsafely.

This change provides some code clarity, but should not affect the
correctness of the code -- it was correct before.

The session variable in conn was accessed after _useSession was
polled via an atomic.Load(), but this obscured the safety of
loads and stores of conn.session.

This change introcuces an atomic.Pointer for clarity, and also
guarantees that if conn.session is accessed without first verifying
useSession that conn will not be accessed unsafely.

This change provides some code clarity, but should not affect the
correctness of the code.
@arashpayan arashpayan merged commit d08a39b into main Mar 17, 2026
2 checks passed
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