From 9dbb3ea3fc1e5d5c3966db467958e3c82219e49e Mon Sep 17 00:00:00 2001 From: Xing Xing Date: Thu, 15 Jan 2015 10:26:53 +0800 Subject: [PATCH] added lock-write to co-ordinate package sequence #56 --- worker/agent.go | 7 +++++++ worker/worker.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) 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 }