1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00

fix crash

This commit is contained in:
Shelikhoo 2016-08-14 20:40:59 +08:00
parent 49441a5050
commit 5e576e11bb
No known key found for this signature in database
GPG Key ID: 7791BDB0709ABD21

View File

@ -126,7 +126,9 @@ func (ws *wsconn) Write(b []byte) (n int, err error) {
}
func (ws *wsconn) Close() error {
ws.connClosing = true
ws.wlock.Lock()
ws.wsc.WriteControl(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""), time.Now().Add((time.Second * 5)))
ws.wlock.Unlock()
err := ws.wsc.Close()
return err
}
@ -186,7 +188,9 @@ func (ws *wsconn) pingPong() {
go func() {
for !ws.connClosing {
ws.wlock.Lock()
ws.wsc.WriteMessage(websocket.PingMessage, nil)
ws.wlock.Unlock()
tick := time.NewTicker(time.Second * 3)
select {