Skip to content

Commit

Permalink
internal/binarylog: Fix data race when calling Write() and Close() in…
Browse files Browse the repository at this point in the history
… parallel (#4604)

They both touched bufferedSink.writeTicker
  • Loading branch information
Jille committed Jul 20, 2021
1 parent ce7bdf5 commit 65cabd7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/binarylog/sink.go
Expand Up @@ -133,12 +133,12 @@ func (fs *bufferedSink) startFlushGoroutine() {
}

func (fs *bufferedSink) Close() error {
fs.mu.Lock()
defer fs.mu.Unlock()
if fs.writeTicker != nil {
fs.writeTicker.Stop()
}
close(fs.done)
fs.mu.Lock()
defer fs.mu.Unlock()
if err := fs.buf.Flush(); err != nil {
grpclogLogger.Warningf("failed to flush to Sink: %v", err)
}
Expand Down

0 comments on commit 65cabd7

Please sign in to comment.