mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-07 20:45:53 +08:00
fix concurrent write panic #6
This commit is contained in:
parent
d1505ec15d
commit
3aea70e92a
@ -170,7 +170,9 @@ func (c *websocketClient) listenApi(conn *wsc.Conn, u bool) {
|
|||||||
if j.Get("echo").Exists() {
|
if j.Get("echo").Exists() {
|
||||||
ret["echo"] = j.Get("echo").Value()
|
ret["echo"] = j.Get("echo").Value()
|
||||||
}
|
}
|
||||||
|
c.pushLock.Lock()
|
||||||
_, _ = conn.Write([]byte(ret.ToJson()))
|
_, _ = conn.Write([]byte(ret.ToJson()))
|
||||||
|
c.pushLock.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if c.conf.ReverseReconnectInterval != 0 {
|
if c.conf.ReverseReconnectInterval != 0 {
|
||||||
@ -276,7 +278,9 @@ func (s *websocketServer) listenApi(c *websocket.Conn) {
|
|||||||
if j.Get("echo").Exists() {
|
if j.Get("echo").Exists() {
|
||||||
ret["echo"] = j.Get("echo").Value()
|
ret["echo"] = j.Get("echo").Value()
|
||||||
}
|
}
|
||||||
|
s.pushLock.Lock()
|
||||||
_ = c.WriteJSON(ret)
|
_ = c.WriteJSON(ret)
|
||||||
|
s.pushLock.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user