From 0d5eca9683f8df261a6b0981393add6ec9b0967e Mon Sep 17 00:00:00 2001 From: chenxingyu Date: Wed, 10 Aug 2016 10:44:20 +0800 Subject: [PATCH] fix go race bug --- command/agent/gated_writer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/command/agent/gated_writer.go b/command/agent/gated_writer.go index e9417c4b09..e1400e62a9 100644 --- a/command/agent/gated_writer.go +++ b/command/agent/gated_writer.go @@ -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)