From c3047fba01a097ebad474614149dcf8abf10894a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=A5=E6=B5=B7?= Date: Wed, 22 Nov 2023 21:08:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=8A=82=E7=82=B9=E6=96=AD=E5=BC=80?= =?UTF-8?q?=E5=90=8E=E5=88=97=E8=A1=A8=E8=BF=98=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/workhub/main.go | 4 ++-- module/workhub/poolman.go | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/module/workhub/main.go b/module/workhub/main.go index 3e347581..df913315 100644 --- a/module/workhub/main.go +++ b/module/workhub/main.go @@ -57,11 +57,11 @@ func Connect(ws *websocket.Conn, rq *ConnectParam) error { func Receiver(worker *Worker) error { + defer DeleteWorker(worker) + recv := &RecvPod{worker} resp := &RespPod{worker} - defer delete(workerPool, worker.WorkerId) - for { var rq *SocketData diff --git a/module/workhub/poolman.go b/module/workhub/poolman.go index b12a23ab..20016a88 100644 --- a/module/workhub/poolman.go +++ b/module/workhub/poolman.go @@ -2,6 +2,8 @@ package workhub import ( "time" + + "github.com/opentdp/go-helper/logman" ) var workerResp = map[uint]any{} @@ -9,6 +11,8 @@ var workerPool = map[string]*Worker{} func DeleteWorker(Worker *Worker) { + logman.Info("Worker disconnect", "Id", Worker.WorkerId) + if Worker.WorkerId != "" { delete(workerPool, Worker.WorkerId) }