Fix(atomic panic): 64-bit fields must be 64-bit aligned on 32-bit systems (#358)

This commit is contained in:
Loyalsoldier
2021-06-03 11:00:44 +08:00
committed by GitHub
parent 7f8d638260
commit 068d23371c
3 changed files with 28 additions and 10 deletions
+12 -6
View File
@@ -17,12 +17,18 @@ import (
const Name = "MEMORY"
type User struct {
sent uint64
recv uint64
lastSent uint64
lastRecv uint64
sendSpeed uint64
recvSpeed uint64
// WARNING: do not change the order of these fields.
// 64-bit fields that use `sync/atomic` package functions
// must be 64-bit aligned on 32-bit systems.
// Reference: https://github.com/golang/go/issues/599
// Solution: https://github.com/golang/go/issues/11891#issuecomment-433623786
sent uint64
recv uint64
lastSent uint64
lastRecv uint64
sendSpeed uint64
recvSpeed uint64
hash string
ipTable sync.Map
ipNum int32
+8 -2
View File
@@ -29,9 +29,15 @@ const (
)
type OutboundConn struct {
// WARNING: do not change the order of these fields.
// 64-bit fields that use `sync/atomic` package functions
// must be 64-bit aligned on 32-bit systems.
// Reference: https://github.com/golang/go/issues/599
// Solution: https://github.com/golang/go/issues/11891#issuecomment-433623786
sent uint64
recv uint64
metadata *tunnel.Metadata
sent uint64
recv uint64
user statistic.User
headerWrittenOnce sync.Once
net.Conn
+8 -2
View File
@@ -21,9 +21,15 @@ import (
// InboundConn is a trojan inbound connection
type InboundConn struct {
// WARNING: do not change the order of these fields.
// 64-bit fields that use `sync/atomic` package functions
// must be 64-bit aligned on 32-bit systems.
// Reference: https://github.com/golang/go/issues/599
// Solution: https://github.com/golang/go/issues/11891#issuecomment-433623786
sent uint64
recv uint64
net.Conn
sent uint64
recv uint64
auth statistic.Authenticator
user statistic.User
hash string