@@ -68,7 +68,7 @@ func NetConn(ctx context.Context, c *Conn, msgType MessageType) net.Conn {
6868 defer nc .writeMu .unlock ()
6969
7070 // Prevents future writes from writing until the deadline is reset.
71- atomic . StoreInt64 ( & nc .writeExpired , 1 )
71+ nc .writeExpired . Store ( 1 )
7272 })
7373 if ! nc .writeTimer .Stop () {
7474 <- nc .writeTimer .C
@@ -84,7 +84,7 @@ func NetConn(ctx context.Context, c *Conn, msgType MessageType) net.Conn {
8484 defer nc .readMu .unlock ()
8585
8686 // Prevents future reads from reading until the deadline is reset.
87- atomic . StoreInt64 ( & nc .readExpired , 1 )
87+ nc .readExpired . Store ( 1 )
8888 })
8989 if ! nc .readTimer .Stop () {
9090 <- nc .readTimer .C
@@ -94,25 +94,22 @@ func NetConn(ctx context.Context, c *Conn, msgType MessageType) net.Conn {
9494}
9595
9696type 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-
10297 c * Conn
10398 msgType MessageType
10499
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
100+ writeTimer * time.Timer
101+ writeMu * mu
102+ writeExpired atomic.Int64
103+ writeCtx context.Context
104+ writeCancel context.CancelFunc
105+
106+ readTimer * time.Timer
107+ readMu * mu
108+ readExpired atomic.Int64
109+ readCtx context.Context
110+ readCancel context.CancelFunc
111+ readEOFed bool
112+ reader io.Reader
116113}
117114
118115var _ net.Conn = & netConn {}
@@ -129,7 +126,7 @@ func (nc *netConn) Write(p []byte) (int, error) {
129126 nc .writeMu .forceLock ()
130127 defer nc .writeMu .unlock ()
131128
132- if atomic . LoadInt64 ( & nc .writeExpired ) == 1 {
129+ if nc .writeExpired . Load ( ) == 1 {
133130 return 0 , fmt .Errorf ("failed to write: %w" , context .DeadlineExceeded )
134131 }
135132
@@ -157,7 +154,7 @@ func (nc *netConn) Read(p []byte) (int, error) {
157154}
158155
159156func (nc * netConn ) read (p []byte ) (int , error ) {
160- if atomic . LoadInt64 ( & nc .readExpired ) == 1 {
157+ if nc .readExpired . Load ( ) == 1 {
161158 return 0 , fmt .Errorf ("failed to read: %w" , context .DeadlineExceeded )
162159 }
163160
@@ -209,7 +206,7 @@ func (nc *netConn) SetDeadline(t time.Time) error {
209206}
210207
211208func (nc * netConn ) SetWriteDeadline (t time.Time ) error {
212- atomic . StoreInt64 ( & nc .writeExpired , 0 )
209+ nc .writeExpired . Store ( 0 )
213210 if t .IsZero () {
214211 nc .writeTimer .Stop ()
215212 } else {
@@ -223,7 +220,7 @@ func (nc *netConn) SetWriteDeadline(t time.Time) error {
223220}
224221
225222func (nc * netConn ) SetReadDeadline (t time.Time ) error {
226- atomic . StoreInt64 ( & nc .readExpired , 0 )
223+ nc .readExpired . Store ( 0 )
227224 if t .IsZero () {
228225 nc .readTimer .Stop ()
229226 } else {
0 commit comments