[tor-commits] [snowflake/master] Restore sending close message before closing
arlo at torproject.org
arlo at torproject.org
Mon Nov 11 22:20:29 UTC 2019
commit abefae158716b9f56692ea16336c1f8185eda27e
Author: Arlo Breault <arlolra at gmail.com>
Date: Mon Nov 11 16:59:33 2019 -0500
Restore sending close message before closing
And simplify EOF check.
---
server/server.go | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/server/server.go b/server/server.go
index d111fce..ce804fc 100644
--- a/server/server.go
+++ b/server/server.go
@@ -77,12 +77,10 @@ func (conn *webSocketConn) Read(b []byte) (n int, err error) {
}
n, err = conn.r.Read(b)
- if err != nil {
- if err == io.EOF {
- // Message finished
- conn.r = nil
- err = nil
- }
+ if err == io.EOF {
+ // Message finished
+ conn.r = nil
+ err = nil
}
return
}
@@ -102,6 +100,8 @@ func (conn *webSocketConn) Write(b []byte) (n int, err error) {
// Implements io.Closer.
func (conn *webSocketConn) Close() error {
+ // Ignore any error in trying to write a Close frame.
+ _ = conn.Ws.WriteControl(websocket.CloseMessage, []byte{}, time.Now().Add(time.Second))
return conn.Ws.Close()
}
More information about the tor-commits
mailing list