internal/binarylog: Fix data race when calling Write() and Close() in parallel (#4604)

They both touched bufferedSink.writeTicker
This commit is contained in:
Jille Timmermans 2021-07-20 19:58:14 +02:00 committed by GitHub
parent ce7bdf50ab
commit 65cabd74d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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)
}