[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake/master] Restore sending close message before closing



commit abefae158716b9f56692ea16336c1f8185eda27e
Author: Arlo Breault <arlolra@xxxxxxxxx>
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()
 }
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits