mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-07 04:23:49 +08:00
fix: data race && cgo build.
This commit is contained in:
parent
c6994ade94
commit
ca93d4de0d
@ -33,8 +33,8 @@ var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
type CQBot struct {
|
||||
Client *client.QQClient
|
||||
|
||||
lock sync.RWMutex
|
||||
events []func(*Event)
|
||||
mu sync.Mutex
|
||||
|
||||
db *leveldb.DB
|
||||
friendReqCache sync.Map
|
||||
@ -154,9 +154,9 @@ func NewQQBot(cli *client.QQClient, conf *config.Config) *CQBot {
|
||||
|
||||
// OnEventPush 注册事件上报函数
|
||||
func (bot *CQBot) OnEventPush(f func(e *Event)) {
|
||||
bot.mu.Lock()
|
||||
defer bot.mu.Unlock()
|
||||
bot.lock.Lock()
|
||||
bot.events = append(bot.events, f)
|
||||
bot.lock.Unlock()
|
||||
}
|
||||
|
||||
// GetMessage 获取给定消息id对应的消息
|
||||
@ -432,6 +432,9 @@ func (bot *CQBot) Release() {
|
||||
}
|
||||
|
||||
func (bot *CQBot) dispatchEventMessage(m MSG) {
|
||||
bot.lock.RLock()
|
||||
defer bot.lock.RUnlock()
|
||||
|
||||
event := &Event{RawMsg: m}
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(len(bot.events))
|
||||
|
@ -1,5 +1,6 @@
|
||||
// +build linux windows,!arm darwin
|
||||
// +build 386 amd64 arm arm64
|
||||
// +build !cgo
|
||||
|
||||
// Package codec Slik编码核心模块
|
||||
package codec
|
||||
|
@ -1,4 +1,4 @@
|
||||
// +build !arm,!arm64,!amd64,!386
|
||||
// +build !arm,!arm64,!amd64,!386 cgo
|
||||
|
||||
package codec
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user