From 8baae350141b8eeb528154c579f1b9df228e49bc Mon Sep 17 00:00:00 2001 From: lwch Date: Wed, 1 Sep 2021 11:33:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3server=E7=AB=AF=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=93=BE=E6=8E=A5=E6=97=B6=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/server/handler/client.go | 4 ++++ code/server/handler/handler.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/code/server/handler/client.go b/code/server/handler/client.go index e131d71..5c58c95 100644 --- a/code/server/handler/client.go +++ b/code/server/handler/client.go @@ -86,3 +86,7 @@ func (c *client) closeLink(id string) { delete(c.links, id) c.Unlock() } + +func (c *client) is(id string, idx uint32) bool { + return c.parent.id == id && c.idx == idx +} diff --git a/code/server/handler/handler.go b/code/server/handler/handler.go index 9c25307..b24e709 100644 --- a/code/server/handler/handler.go +++ b/code/server/handler/handler.go @@ -99,10 +99,10 @@ func (h *Handler) getClient(linkID, to string, toIdx uint32) *client { pair := h.links[linkID] h.lockLinks.RUnlock() - if pair[0] != nil && pair[0].idx == toIdx { + if pair[0] != nil && pair[0].is(to, toIdx) { return pair[0] } - if pair[1] != nil && pair[1].idx == toIdx { + if pair[1] != nil && pair[1].is(to, toIdx) { return pair[1] }