From abd6ce9be3708ace06bdcf6ea6780b594dde0630 Mon Sep 17 00:00:00 2001 From: yuxh Date: Mon, 13 Feb 2023 01:01:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E7=94=A8Close=E5=90=8E=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E5=90=91JobServer=E8=8E=B7=E5=8F=96=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worker/agent.go | 11 ++++++++--- worker/worker.go | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) 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{}{} }