good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit ff63b191 authored by Anmol Sethi's avatar Anmol Sethi
Browse files

Fix unaligned 64 bit atomic loads on 32 bit platforms

Closes #153
parent 0e007607
Branches
Tags
No related merge requests found
......@@ -70,7 +70,8 @@ type Conn struct {
activeReader *messageReader
// readFrameLock is acquired to read from bw.
readFrameLock chan struct{}
readClosed int64
// Not int32 because of https://github.com/nhooyr/websocket/issues/153
readClosed int32
readHeaderBuf []byte
controlPayloadBuf []byte
......@@ -341,7 +342,7 @@ func (c *Conn) handleControl(ctx context.Context, h header) error {
// See https://github.com/nhooyr/websocket/issues/87#issue-451703332
// Most users should not need this.
func (c *Conn) Reader(ctx context.Context) (MessageType, io.Reader, error) {
if atomic.LoadInt64(&c.readClosed) == 1 {
if atomic.LoadInt32(&c.readClosed) == 1 {
return 0, nil, fmt.Errorf("websocket connection read closed")
}
......
......@@ -178,7 +178,7 @@ func (c *netConn) SetReadDeadline(t time.Time) error {
// Use this when you do not want to read data messages from the connection anymore but will
// want to write messages to it.
func (c *Conn) CloseRead(ctx context.Context) context.Context {
atomic.StoreInt64(&c.readClosed, 1)
atomic.StoreInt32(&c.readClosed, 1)
ctx, cancel := context.WithCancel(ctx)
go func() {
......
......@@ -89,7 +89,7 @@ func (c *Conn) closeWithInternal() {
// Read attempts to read a message from the connection.
// The maximum time spent waiting is bounded by the context.
func (c *Conn) Read(ctx context.Context) (MessageType, []byte, error) {
if atomic.LoadInt64(&c.readClosed) == 1 {
if atomic.LoadInt32(&c.readClosed) == 1 {
return 0, nil, fmt.Errorf("websocket connection read closed")
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment