Skip to content

Commit

Permalink
fixup! ws_js: Update to match new close code
Browse files Browse the repository at this point in the history
  • Loading branch information
nhooyr committed Apr 6, 2024
1 parent a9e9d67 commit 684adf9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions read.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ func (c *Conn) Read(ctx context.Context) (MessageType, []byte, error) {
// This function is idempotent.
func (c *Conn) CloseRead(ctx context.Context) context.Context {
c.closeReadMu.Lock()
if c.closeReadCtx != nil {
ctx := c.closeReadCtx

Check failure on line 67 in read.go

View workflow job for this annotation

GitHub Actions / lint

no new variables on left side of :=

Check failure on line 67 in read.go

View workflow job for this annotation

GitHub Actions / lint

no new variables on left side of :=

Check failure on line 67 in read.go

View workflow job for this annotation

GitHub Actions / bench

no new variables on left side of :=
if ctx != nil {
c.closeReadMu.Unlock()
return c.closeReadCtx
return ctx
}
ctx, cancel := context.WithCancel(ctx)
c.closeReadCtx = ctx
Expand Down
5 changes: 3 additions & 2 deletions ws_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,10 @@ func (w *writer) Close() error {
// CloseRead implements *Conn.CloseRead for wasm.
func (c *Conn) CloseRead(ctx context.Context) context.Context {
c.closeReadMu.Lock()
if c.closeReadCtx != nil {
ctx := c.closeReadCtx
if ctx != nil {
c.closeReadMu.Unlock()
return c.closeReadCtx
return ctx
}
ctx, cancel := context.WithCancel(ctx)
c.closeReadCtx = ctx
Expand Down

0 comments on commit 684adf9

Please sign in to comment.