Commit 3aea70e9 authored by Mrs4s's avatar Mrs4s

fix concurrent write panic #6

parent d1505ec1
...@@ -170,7 +170,9 @@ func (c *websocketClient) listenApi(conn *wsc.Conn, u bool) { ...@@ -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) { ...@@ -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()
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment