diff --git a/worker/agent.go b/worker/agent.go index 5c2b384..659960a 100644 --- a/worker/agent.go +++ b/worker/agent.go @@ -200,3 +200,10 @@ func (a *agent) write(outpack *outPack) (err error) { } return a.rw.Flush() } + +// Write with lock +func (a *agent) Write(outpack *outPack) (err error) { + a.Lock() + defer a.Unlock() + return a.write(outpack) +} diff --git a/worker/worker.go b/worker/worker.go index c8c91db..25d6a60 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -292,7 +292,7 @@ func (worker *Worker) exec(inpack *inPack) (err error) { } outpack.handle = inpack.handle outpack.data = r.data - inpack.a.write(outpack) + inpack.a.Write(outpack) } return }