Skip to content

Commit

Permalink
Make sure uint64 is aligned for its use on x86-32 and ARM
Browse files Browse the repository at this point in the history
  • Loading branch information
uaalto committed Sep 2, 2015
1 parent a3e331d commit f3e4c35
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/github.com/getlantern/detour/detour.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ var (
// Conn implements an net.Conn interface by utilizing underlie direct and
// detour connections.
type Conn struct {
// Keeps track of the total bytes read from this connection, atomic
// Due to https://golang.org/pkg/sync/atomic/#pkg-note-BUG it requires
// manual alignment. For this, it is best to keep it as the first field
readBytes uint64

// The underlie connections, uses buffered channel as ring queue to avoid
// locking. We have at most 2 connetions so a length of 2 is enough.
conns chan conn
Expand All @@ -70,9 +75,6 @@ type Conn struct {
// The chan to receive result of any write operation
chWrite chan ioResult

// Keeps track of the total bytes read from this connection, atomic
readBytes uint64

addr string

muWriteBuffer sync.RWMutex
Expand Down

0 comments on commit f3e4c35

Please sign in to comment.