8000 fix closenow race by alixander · Pull Request #427 · coder/websocket · GitHub
[go: up one dir, main page]

Skip to content

fix closenow race #427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ws_js_test: Fix
  • Loading branch information
nhooyr committed Apr 7, 2024
commit 211ef4bcce3f6cf639c870a00d464a2676416066
4 changes: 0 additions & 4 deletions close.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ func (c *Conn) waitCloseHandshake() error {
}
defer c.readMu.unlock()

if c.readCloseFrameErr != nil {
return c.readCloseFrameErr
}

for i := int64(0); i < c.msgReader.payloadLength; i++ {
_, err := c.br.ReadByte()
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type Conn struct {
readHeaderBuf [8]byte
readControlBuf [maxControlPayload]byte
msgReader *msgReader
readCloseFrameErr error

// Write state.
msgWriter *msgWriter
Expand Down
2 changes: 1 addition & 1 deletion conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func TestWasm(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

cmd := exec.CommandContext(ctx, "go", "test", "-exec=wasmbrowsertest", ".")
cmd := exec.CommandContext(ctx, "go", "test", "-exec=wasmbrowsertest", ".", "-v")
cmd.Env = append(os.Environ(), "GOOS=js", "GOARCH=wasm", fmt.Sprintf("WS_ECHO_SERVER_URL=%v", s.URL))

b, err := cmd.CombinedOutput()
Expand Down
6 changes: 3 additions & 3 deletions read.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,7 @@ func (c *Conn) handleControl(ctx context.Context, h header) (err error) {
return nil
}

defer func() {
c.readCloseFrameErr = err
}()
// opClose

ce, err := parseClosePayload(b)
if err != nil {
Expand All @@ -326,6 +324,8 @@ func (c *Conn) handleControl(ctx context.Context, h header) (err error) {

err = fmt.Errorf("received close frame: %w", ce)
c.writeClose(ce.Code, ce.Reason)
c.readMu.unlock()
c.close()
return err
}

Expand Down
0