Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commitcce7843

Browse files
authored
fix: wsnet.(*Dialer).DialContext hangs forever if ctx is cancelled (#425)
1 parent1f35561 commitcce7843

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

‎wsnet/dial.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,19 +392,22 @@ func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.
392392
ctx,cancel:=context.WithTimeout(ctx,time.Second*5)
393393
defercancel()
394394

395-
errCh:=make(chanerror)
395+
errCh:=make(chanerror,1)
396396
gofunc() {
397+
deferclose(errCh)
398+
397399
varresDialChannelResponse
398400
err=json.NewDecoder(rw).Decode(&res)
399401
iferr!=nil {
400402
errCh<-fmt.Errorf("read dial response: %w",err)
401403
return
402404
}
405+
403406
d.log.Debug(ctx,"dial response",slog.F("res",res))
404407
ifres.Err=="" {
405-
close(errCh)
406408
return
407409
}
410+
408411
err:=errors.New(res.Err)
409412
ifres.Code==CodeDialErr {
410413
err=&net.OpError{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp