added lock-write to co-ordinate package sequence #56

This commit is contained in:
Xing Xing 2015-01-15 10:26:53 +08:00
parent c01a2e22c0
commit 9dbb3ea3fc
2 changed files with 8 additions and 1 deletions

View File

@ -200,3 +200,10 @@ func (a *agent) write(outpack *outPack) (err error) {
} }
return a.rw.Flush() return a.rw.Flush()
} }
// Write with lock
func (a *agent) Write(outpack *outPack) (err error) {
a.Lock()
defer a.Unlock()
return a.write(outpack)
}

View File

@ -292,7 +292,7 @@ func (worker *Worker) exec(inpack *inPack) (err error) {
} }
outpack.handle = inpack.handle outpack.handle = inpack.handle
outpack.data = r.data outpack.data = r.data
inpack.a.write(outpack) inpack.a.Write(outpack)
} }
return return
} }