From b8b4aba13df0af7d86e7eb97f443c8dca577afc0 Mon Sep 17 00:00:00 2001 From: wfjsw Date: Fri, 21 Aug 2020 13:36:28 +0800 Subject: [PATCH] Lock the sequence counter in nextSeq Did you smell that race condition? --- client/client.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/client.go b/client/client.go index 8ecf8112..361a7530 100644 --- a/client/client.go +++ b/client/client.go @@ -77,6 +77,8 @@ type QQClient struct { groupListLock sync.Mutex msgSvcLock sync.Mutex + + seqLock sync.Mutex } type loginSigInfo struct { @@ -818,6 +820,9 @@ func (c *QQClient) registerClient() { } func (c *QQClient) nextSeq() uint16 { + c.seqLock.Lock() + defer c.seqLock.Unlock() + c.SequenceId++ c.SequenceId &= 0x7FFF if c.SequenceId == 0 {