From b371dcc009d83fa39d7358b41817904c4bbcc3b2 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov <iamolegkovalov@gmail.com> Date: Fri, 27 Sep 2019 15:30:11 -0500 Subject: [PATCH] Rename readClosed to isReadClosed Closes #150 --- conn.go | 8 ++++---- conn_common.go | 2 +- websocket_js.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/conn.go b/conn.go index 2679edc..37c4cac 100644 --- a/conn.go +++ b/conn.go @@ -55,7 +55,7 @@ type Conn struct { writeHeaderBuf []byte writeHeader *header // read limit for a message in bytes. - msgReadLimit *atomicInt64 + msgReadLimit *atomicInt64 // Used to ensure a previous writer is not used after being closed. activeWriter atomic.Value @@ -69,7 +69,7 @@ type Conn struct { activeReader *messageReader // readFrameLock is acquired to read from bw. readFrameLock chan struct{} - readClosed *atomicInt64 + isReadClosed *atomicInt64 readHeaderBuf []byte controlPayloadBuf []byte @@ -105,7 +105,7 @@ func (c *Conn) init() { c.writeHeaderBuf = makeWriteHeaderBuf() c.writeHeader = &header{} c.readHeaderBuf = makeReadHeaderBuf() - c.readClosed = &atomicInt64{} + c.isReadClosed = &atomicInt64{} c.controlPayloadBuf = make([]byte, maxControlFramePayload) runtime.SetFinalizer(c, func(c *Conn) { @@ -342,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 c.readClosed.Load() == 1 { + if c.isReadClosed.Load() == 1 { return 0, nil, fmt.Errorf("websocket connection read closed") } diff --git a/conn_common.go b/conn_common.go index 4714611..e7a0103 100644 --- a/conn_common.go +++ b/conn_common.go @@ -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 { - c.readClosed.Store(1) + c.isReadClosed.Store(1) ctx, cancel := context.WithCancel(ctx) go func() { diff --git a/websocket_js.go b/websocket_js.go index 2226d3a..d70ccfc 100644 --- a/websocket_js.go +++ b/websocket_js.go @@ -23,7 +23,7 @@ type Conn struct { // read limit for a message in bytes. msgReadLimit *atomicInt64 - readClosed *atomicInt64 + isReadClosed *atomicInt64 closeOnce sync.Once closed chan struct{} closeErrOnce sync.Once @@ -53,7 +53,7 @@ func (c *Conn) init() { c.msgReadLimit = &atomicInt64{} c.msgReadLimit.Store(32768) - c.readClosed = &atomicInt64{} + c.isReadClosed = &atomicInt64{} c.releaseOnClose = c.ws.OnClose(func(e wsjs.CloseEvent) { cerr := CloseError{ @@ -93,7 +93,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 c.readClosed.Load() == 1 { + if c.isReadClosed.Load() == 1 { return 0, nil, fmt.Errorf("websocket connection read closed") } -- GitLab