fix go race bug

This commit is contained in:
chenxingyu 2016-08-10 10:44:20 +08:00
parent 3367f427b4
commit 53009f2466
1 changed files with 2 additions and 2 deletions

View File

@ -29,8 +29,8 @@ func (w *GatedWriter) Flush() {
}
func (w *GatedWriter) Write(p []byte) (n int, err error) {
w.lock.RLock()
defer w.lock.RUnlock()
w.lock.Lock()
defer w.lock.Unlock()
if w.flush {
return w.Writer.Write(p)