mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-03 07:56:42 -05:00
fix crash
This commit is contained in:
parent
49441a5050
commit
5e576e11bb
@ -126,7 +126,9 @@ func (ws *wsconn) Write(b []byte) (n int, err error) {
|
|||||||
}
|
}
|
||||||
func (ws *wsconn) Close() error {
|
func (ws *wsconn) Close() error {
|
||||||
ws.connClosing = true
|
ws.connClosing = true
|
||||||
|
ws.wlock.Lock()
|
||||||
ws.wsc.WriteControl(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""), time.Now().Add((time.Second * 5)))
|
ws.wsc.WriteControl(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""), time.Now().Add((time.Second * 5)))
|
||||||
|
ws.wlock.Unlock()
|
||||||
err := ws.wsc.Close()
|
err := ws.wsc.Close()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -186,7 +188,9 @@ func (ws *wsconn) pingPong() {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for !ws.connClosing {
|
for !ws.connClosing {
|
||||||
|
ws.wlock.Lock()
|
||||||
ws.wsc.WriteMessage(websocket.PingMessage, nil)
|
ws.wsc.WriteMessage(websocket.PingMessage, nil)
|
||||||
|
ws.wlock.Unlock()
|
||||||
tick := time.NewTicker(time.Second * 3)
|
tick := time.NewTicker(time.Second * 3)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
Loading…
Reference in New Issue
Block a user