Skip to content

Commit

Permalink
fix: concurrent write to websocket connection
Browse files Browse the repository at this point in the history
  • Loading branch information
withchao committed Nov 21, 2024
1 parent af2f020 commit 7859013
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/msggateway/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,11 @@ func (c *Client) handlerTextMessage(b []byte) error {
if err != nil {
return err
}
c.w.Lock()
defer c.w.Unlock()
if err := c.conn.SetWriteDeadline(writeWait); err != nil {
return err
}
c.w.Lock()
defer c.w.Unlock()
return c.conn.WriteMessage(MessageText, msgData)
default:
return fmt.Errorf("not support message type %s", msg.Type)
Expand Down

0 comments on commit 7859013

Please sign in to comment.