Skip to content

Commit

Permalink
fix concurrent write panic #6
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrs4s committed Jul 30, 2020
1 parent d1505ec commit 3aea70e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
}
}
}
Expand Down

0 comments on commit 3aea70e

Please sign in to comment.