Fix a race in daemon/logger.TestCopier
Update #22963 Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
parent
29dbcbad87
commit
ab533f0651
1 changed files with 4 additions and 0 deletions
|
@ -4,12 +4,14 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
type TestLoggerJSON struct {
|
||||
*json.Encoder
|
||||
mu sync.Mutex
|
||||
delay time.Duration
|
||||
}
|
||||
|
||||
|
@ -17,6 +19,8 @@ func (l *TestLoggerJSON) Log(m *Message) error {
|
|||
if l.delay > 0 {
|
||||
time.Sleep(l.delay)
|
||||
}
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
return l.Encode(m)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue