Skip to content

Commit 8d2374e

Browse files
committed
Merge pull request #438 from x0wllaar/fix-netconn-alignment
Fix unaligned load error on 32-bit architectures Closes #432
2 parents 819f9d1 + 1cc90bb commit 8d2374e

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

netconn.go

+16-13
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,25 @@ func NetConn(ctx context.Context, c *Conn, msgType MessageType) net.Conn {
9494
}
9595

9696
type netConn struct {
97+
// These must be first to be aligned on 32 bit platforms.
98+
// https://github.com/nhooyr/websocket/pull/438
99+
readExpired int64
100+
writeExpired int64
101+
97102
c *Conn
98103
msgType MessageType
99104

100-
writeTimer *time.Timer
101-
writeMu *mu
102-
writeExpired int64
103-
writeCtx context.Context
104-
writeCancel context.CancelFunc
105-
106-
readTimer *time.Timer
107-
readMu *mu
108-
readExpired int64
109-
readCtx context.Context
110-
readCancel context.CancelFunc
111-
readEOFed bool
112-
reader io.Reader
105+
writeTimer *time.Timer
106+
writeMu *mu
107+
writeCtx context.Context
108+
writeCancel context.CancelFunc
109+
110+
readTimer *time.Timer
111+
readMu *mu
112+
readCtx context.Context
113+
readCancel context.CancelFunc
114+
readEOFed bool
115+
reader io.Reader
113116
}
114117

115118
var _ net.Conn = &netConn{}

0 commit comments

Comments
 (0)