mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
Lock the sequence counter in nextSeq
Did you smell that race condition?
This commit is contained in:
parent
85a81c88b7
commit
b8b4aba13d
@ -77,6 +77,8 @@ type QQClient struct {
|
|||||||
|
|
||||||
groupListLock sync.Mutex
|
groupListLock sync.Mutex
|
||||||
msgSvcLock sync.Mutex
|
msgSvcLock sync.Mutex
|
||||||
|
|
||||||
|
seqLock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
type loginSigInfo struct {
|
type loginSigInfo struct {
|
||||||
@ -818,6 +820,9 @@ func (c *QQClient) registerClient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *QQClient) nextSeq() uint16 {
|
func (c *QQClient) nextSeq() uint16 {
|
||||||
|
c.seqLock.Lock()
|
||||||
|
defer c.seqLock.Unlock()
|
||||||
|
|
||||||
c.SequenceId++
|
c.SequenceId++
|
||||||
c.SequenceId &= 0x7FFF
|
c.SequenceId &= 0x7FFF
|
||||||
if c.SequenceId == 0 {
|
if c.SequenceId == 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user