diff --git a/worker/agent.go b/worker/agent.go index 3996a61..fd70df6 100644 --- a/worker/agent.go +++ b/worker/agent.go @@ -143,10 +143,14 @@ func (a *agent) Grab() { a.grab() } -func (a *agent) grab() { +func (a *agent) grab() bool { + if a.worker.closed != nil { + return false + } outpack := getOutPack() outpack.dataType = dtGrabJobUniq a.write(outpack) + return true } func (a *agent) PreSleep() { @@ -169,9 +173,10 @@ func (a *agent) reconnect() error { bufio.NewWriter(a.conn)) a.worker.reRegisterFuncsForAgent(a) - a.grab() + if a.grab() { + go a.work() + } - go a.work() return nil } diff --git a/worker/worker.go b/worker/worker.go index 0ea022f..c17c9fc 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -344,7 +344,7 @@ func (worker *Worker) exec(inpack *inPack) (err error) { } outpack.handle = inpack.handle outpack.data = r.data - err = inpack.a.Write(outpack) + _ = inpack.a.Write(outpack) if worker.leftJobs != nil { worker.leftJobs <- struct{}{} }