1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-06 03:53:50 +08:00

fix concurrent write panic #6

This commit is contained in:
Mrs4s 2020-07-30 20:04:00 +08:00
parent d1505ec15d
commit 3aea70e92a

View File

@ -170,7 +170,9 @@ func (c *websocketClient) listenApi(conn *wsc.Conn, u bool) {
if j.Get("echo").Exists() {
ret["echo"] = j.Get("echo").Value()
}
c.pushLock.Lock()
_, _ = conn.Write([]byte(ret.ToJson()))
c.pushLock.Unlock()
}
}
if c.conf.ReverseReconnectInterval != 0 {
@ -276,7 +278,9 @@ func (s *websocketServer) listenApi(c *websocket.Conn) {
if j.Get("echo").Exists() {
ret["echo"] = j.Get("echo").Value()
}
s.pushLock.Lock()
_ = c.WriteJSON(ret)
s.pushLock.Unlock()
}
}
}