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: race condition when creating standard logger #68

Merged
merged 1 commit into from
Aug 1, 2023
Merged

Conversation

aymanbagabas
Copy link
Member

@aymanbagabas aymanbagabas commented Jul 28, 2023

Before, StandardLog used to copy the internal buffer causing two or
more loggers to share the same buffer triggering a race.

Don't copy the internal buffer and reduce the mutex critical section
scope.

Fixes: #67

@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Merging #68 (8254a5d) into main (280c4e3) will increase coverage by 0.64%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #68      +/-   ##
==========================================
+ Coverage   76.85%   77.49%   +0.64%     
==========================================
  Files          10       10              
  Lines         635      631       -4     
==========================================
+ Hits          488      489       +1     
+ Misses        132      128       -4     
+ Partials       15       14       -1     
Files Changed Coverage Δ
logger.go 85.07% <100.00%> (+2.31%) ⬆️
stdlog.go 75.00% <100.00%> (-1.20%) ⬇️

@aymanbagabas aymanbagabas changed the title fix: lock buffer during write before read fix: race condition when creating standard logger Aug 1, 2023
Before, `StandardLog` used to _copy_ the internal buffer causing two or
more loggers to share the same buffer triggering a race.

Don't copy the internal buffer and reduce the mutex critical section
scope.
@aymanbagabas aymanbagabas merged commit 97dd8c9 into main Aug 1, 2023
16 checks passed
@aymanbagabas aymanbagabas deleted the write-race branch August 1, 2023 18:57
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.

Data race
2 participants