Skip to content

Commit b371dcc

Browse files
cristalolegnhooyr
authored andcommitted
Rename readClosed to isReadClosed
Closes #150
1 parent 31df3a5 commit b371dcc

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

conn.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ type Conn struct {
5555
writeHeaderBuf []byte
5656
writeHeader *header
5757
// read limit for a message in bytes.
58-
msgReadLimit *atomicInt64
58+
msgReadLimit *atomicInt64
5959

6060
// Used to ensure a previous writer is not used after being closed.
6161
activeWriter atomic.Value
@@ -69,7 +69,7 @@ type Conn struct {
6969
activeReader *messageReader
7070
// readFrameLock is acquired to read from bw.
7171
readFrameLock chan struct{}
72-
readClosed *atomicInt64
72+
isReadClosed *atomicInt64
7373
readHeaderBuf []byte
7474
controlPayloadBuf []byte
7575

@@ -105,7 +105,7 @@ func (c *Conn) init() {
105105
c.writeHeaderBuf = makeWriteHeaderBuf()
106106
c.writeHeader = &header{}
107107
c.readHeaderBuf = makeReadHeaderBuf()
108-
c.readClosed = &atomicInt64{}
108+
c.isReadClosed = &atomicInt64{}
109109
c.controlPayloadBuf = make([]byte, maxControlFramePayload)
110110

111111
runtime.SetFinalizer(c, func(c *Conn) {
@@ -342,7 +342,7 @@ func (c *Conn) handleControl(ctx context.Context, h header) error {
342342
// See https://github.com/nhooyr/websocket/issues/87#issue-451703332
343343
// Most users should not need this.
344344
func (c *Conn) Reader(ctx context.Context) (MessageType, io.Reader, error) {
345-
if c.readClosed.Load() == 1 {
345+
if c.isReadClosed.Load() == 1 {
346346
return 0, nil, fmt.Errorf("websocket connection read closed")
347347
}
348348

conn_common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (c *netConn) SetReadDeadline(t time.Time) error {
178178
// Use this when you do not want to read data messages from the connection anymore but will
179179
// want to write messages to it.
180180
func (c *Conn) CloseRead(ctx context.Context) context.Context {
181-
c.readClosed.Store(1)
181+
c.isReadClosed.Store(1)
182182

183183
ctx, cancel := context.WithCancel(ctx)
184184
go func() {

websocket_js.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Conn struct {
2323
// read limit for a message in bytes.
2424
msgReadLimit *atomicInt64
2525

26-
readClosed *atomicInt64
26+
isReadClosed *atomicInt64
2727
closeOnce sync.Once
2828
closed chan struct{}
2929
closeErrOnce sync.Once
@@ -53,7 +53,7 @@ func (c *Conn) init() {
5353
c.msgReadLimit = &atomicInt64{}
5454
c.msgReadLimit.Store(32768)
5555

56-
c.readClosed = &atomicInt64{}
56+
c.isReadClosed = &atomicInt64{}
5757

5858
c.releaseOnClose = c.ws.OnClose(func(e wsjs.CloseEvent) {
5959
cerr := CloseError{
@@ -93,7 +93,7 @@ func (c *Conn) closeWithInternal() {
9393
// Read attempts to read a message from the connection.
9494
// The maximum time spent waiting is bounded by the context.
9595
func (c *Conn) Read(ctx context.Context) (MessageType, []byte, error) {
96-
if c.readClosed.Load() == 1 {
96+
if c.isReadClosed.Load() == 1 {
9797
return 0, nil, fmt.Errorf("websocket connection read closed")
9898
}
9999

0 commit comments

Comments
 (0)