all: switch to Go 1.19 atomics#48139
Merged
thaJeztah merged 12 commits intomoby:masterfrom Jul 15, 2024
Merged
Conversation
Signed-off-by: Cory Snider <[email protected]>
Signed-off-by: Cory Snider <[email protected]>
Signed-off-by: Cory Snider <[email protected]>
Signed-off-by: Cory Snider <[email protected]>
Signed-off-by: Cory Snider <[email protected]>
Signed-off-by: Cory Snider <[email protected]>
Signed-off-by: Cory Snider <[email protected]>
thaJeztah
approved these changes
Jul 7, 2024
Member
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM
one question about the int32 -> uint32 (but just to double check)
| createFile(t, name, "hi there") | ||
|
|
||
| var conversions int32 | ||
| var conversions atomic.Uint32 |
Member
There was a problem hiding this comment.
This changed to a uint; I'm guessing that was intentional?
| func (s *Server) IsDiagnosticEnabled() bool { | ||
| s.mu.Lock() | ||
| defer s.mu.Unlock() | ||
| return s.enable == 1 |
akerouanton
approved these changes
Jul 8, 2024
Member
akerouanton
left a comment
There was a problem hiding this comment.
Overall LGTM, but left a few nits.
If it's worth changing conversions from int32 to atomic.Uint32 because it's never decremented, it's probably worth doing the same for the other vars.
vvoland
approved these changes
Jul 8, 2024
Signed-off-by: Cory Snider <[email protected]>
It was unnecessary; access to the variable was synchronized through a mutex in all cases but one, where synchonizing through the mutex would work just fine without any chance of deadlocks. Signed-off-by: Cory Snider <[email protected]>
Signed-off-by: Cory Snider <[email protected]>
Signed-off-by: Cory Snider <[email protected]>
Signed-off-by: Cory Snider <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
- What I did
Got rid of all instances of old-style atomic operations which operate on pointers to primitive variables. Added a lint rule to forbid old-style atomic operations in the codebase.
- How I did it
I replaced each instance with the most semantically-appropriate Go 1.19 atomic type for the situation, with one exception. The libnetwork diagnostic server was using atomics unsoundly. Most of the variable accesses were synchronized through a mutex, so I just replaced the singular atomic operation with a non-atomic operation, synchronized through the aforementioned mutex.
- How to verify it
Unit tests
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)