mirror of https://github.com/gorilla/websocket.git
perf: reduce timer in write_control
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
This commit is contained in:
parent
cf50a3efbb
commit
d15aba1e61
5
conn.go
5
conn.go
|
@ -454,6 +454,9 @@ func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) er
|
|||
}
|
||||
}
|
||||
|
||||
select {
|
||||
case <-c.mu:
|
||||
default:
|
||||
timer := time.NewTimer(d)
|
||||
select {
|
||||
case <-c.mu:
|
||||
|
@ -461,6 +464,8 @@ func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) er
|
|||
case <-timer.C:
|
||||
return errWriteTimeout
|
||||
}
|
||||
}
|
||||
|
||||
defer func() { c.mu <- struct{}{} }()
|
||||
|
||||
c.writeErrMu.Lock()
|
||||
|
|
Loading…
Reference in New Issue