فهرست منبع

Revert da7abf46
* Unnecessary since SSH max packet size ensures
resonable latency.
* May have exposed bug in meek server with short
reads of OSSH seed message.

Rod Hynes 9 سال پیش
والد
کامیت
7189e73e13
1فایلهای تغییر یافته به همراه2 افزوده شده و 30 حذف شده
  1. 2 30
      psiphon/common/throttled.go

+ 2 - 30
psiphon/common/throttled.go

@@ -69,8 +69,6 @@ type ThrottledConn struct {
 	net.Conn
 }
 
-const chunkSize = 4096
-
 // NewThrottledConn initializes a new ThrottledConn.
 func NewThrottledConn(conn net.Conn, limits RateLimits) *ThrottledConn {
 
@@ -119,14 +117,7 @@ func (conn *ThrottledConn) Read(buffer []byte) (int, error) {
 		}
 	}
 
-	// When throttling, read small chunks to avoid
-	// excessive latency due to long waits in limitedReader.Read.
-
-	if len(buffer) <= chunkSize {
-		return conn.limitedReader.Read(buffer)
-	}
-
-	return conn.limitedReader.Read(buffer[0:chunkSize])
+	return conn.limitedReader.Read(buffer)
 }
 
 func (conn *ThrottledConn) Write(buffer []byte) (int, error) {
@@ -140,24 +131,5 @@ func (conn *ThrottledConn) Write(buffer []byte) (int, error) {
 		}
 	}
 
-	// When throttling, write buffer in small chunks to avoid
-	// excessive latency due to long waits in limitedWriter.Write.
-
-	bytesWritten := 0
-
-	for start := 0; start < len(buffer); start += chunkSize {
-		end := start + chunkSize
-		if end > len(buffer) {
-			end = len(buffer)
-		}
-
-		n, err := conn.limitedWriter.Write(buffer[start:end])
-		bytesWritten += n
-		if err != nil {
-			// Note: no ContextError as caller may check for io.EOF, etc.
-			return bytesWritten, err
-		}
-	}
-
-	return bytesWritten, nil
+	return conn.limitedWriter.Write(buffer)
 }