fix deadlock in websocket client conn

This commit is contained in:
ginuerzh
2024-01-12 23:46:22 +08:00
parent c04c28e1fd
commit 01168e9846
7 changed files with 122 additions and 77 deletions

View File

@ -49,15 +49,18 @@ func (c *websocketConn) WriteMessage(messageType int, data []byte) error {
}
func (c *websocketConn) SetDeadline(t time.Time) error {
c.mux.Lock()
defer c.mux.Unlock()
if err := c.SetReadDeadline(t); err != nil {
return err
}
return c.SetWriteDeadline(t)
}
func (c *websocketConn) SetReadDeadline(t time.Time) error {
c.mux.Lock()
defer c.mux.Unlock()
return c.Conn.SetReadDeadline(t)
}
func (c *websocketConn) SetWriteDeadline(t time.Time) error {
c.mux.Lock()
defer c.mux.Unlock()