From 4b613bc741a5f8ed10f07da21ea2fe4aecdebeb1 Mon Sep 17 00:00:00 2001 From: Aceld Date: Mon, 18 Dec 2023 18:12:43 +0800 Subject: [PATCH] fix issue routerSlice deep copy https://github.com/aceld/zinx/issues/293 --- znet/heartbeat.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/znet/heartbeat.go b/znet/heartbeat.go index 18ab2f07..4cb758b7 100644 --- a/znet/heartbeat.go +++ b/znet/heartbeat.go @@ -173,10 +173,14 @@ func (h *HeartbeatChecker) Clone() ziface.IHeartbeatChecker { onRemoteNotAlive: h.onRemoteNotAlive, msgID: h.msgID, router: h.router, - routerSlices: h.routerSlices, conn: nil, // The bound connection needs to be reassigned } + // deep copy routerSlices + for _, handler := range h.routerSlices { + heartbeat.routerSlices = append(heartbeat.routerSlices, handler) + } + return heartbeat }