Просмотр исходного кода

Fixed ARM crash related to 64 bit alignment in a struct required by golang atomic package, see https://golang.org/src/sync/atomic/doc.go#L50

Eugene Fryntov 9 лет назад
Родитель
Сommit
81384dbe6b
2 измененных файлов с 9 добавлено и 5 удалено
  1. 8 3
      psiphon/common/throttled.go
  2. 1 2
      psiphon/tunnel.go

+ 8 - 3
psiphon/common/throttled.go

@@ -57,13 +57,18 @@ type RateLimits struct {
 // The underlying rate limiter uses the token bucket algorithm to
 // calculate delay times for read and write operations.
 type ThrottledConn struct {
-	net.Conn
+	// https://golang.org/src/sync/atomic/doc.go#L50
+	// On both ARM and x86-32, it is the caller's responsibility to arrange for 64-bit
+	// alignment of 64-bit words accessed atomically. The first word in a global
+	// variable or in an allocated struct or slice can be relied upon to be
+	// 64-bit aligned.
 	unlimitedReadBytes  int64
-	limitingReads       int32
-	limitedReader       io.Reader
 	unlimitedWriteBytes int64
+	limitingReads       int32
 	limitingWrites      int32
+	limitedReader       io.Reader
 	limitedWriter       io.Writer
+	net.Conn
 }
 
 // NewThrottledConn initializes a new ThrottledConn.

+ 1 - 2
psiphon/tunnel.go

@@ -606,8 +606,7 @@ func dialSsh(
 	}()
 
 	// Apply throttling (if configured)
-	//throttledConn := common.NewThrottledConn(dialConn, config.RateLimits)
-	throttledConn := dialConn
+	throttledConn := common.NewThrottledConn(dialConn, config.RateLimits)
 
 	// Add obfuscated SSH layer
 	var sshConn net.Conn = throttledConn