fix go race bug

This commit is contained in:
chenxingyu 2016-08-10 10:44:20 +08:00
parent 3367f427b4
commit 53009f2466

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)