fix race
This commit is contained in:
parent
9d7a29fe26
commit
d8913a6354
@ -137,10 +137,14 @@ func (a *agent) read(length int) (data []byte, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var m = sync.Mutex{}
|
||||||
|
|
||||||
// Internal write the encoded job.
|
// Internal write the encoded job.
|
||||||
func (a *agent) write(outpack *outPack) (err error) {
|
func (a *agent) write(outpack *outPack) (err error) {
|
||||||
var n int
|
var n int
|
||||||
buf := outpack.Encode()
|
buf := outpack.Encode()
|
||||||
|
m.Lock()
|
||||||
|
defer m.Unlock()
|
||||||
for i := 0; i < len(buf); i += n {
|
for i := 0; i < len(buf); i += n {
|
||||||
n, err = a.rw.Write(buf[i:])
|
n, err = a.rw.Write(buf[i:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user