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

Commita0606d5

Browse files
coadlerdeansheather
authored andcommitted
fix: wsnet.(*Dialer).DialContext hangs forever if ctx is cancelled (#425)
(cherry picked from commitcce7843)(cherry picked from commitac1fdd7)
1 parent175c42e commita0606d5

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
@@ -386,19 +386,22 @@ func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.
386386
ctx,cancel:=context.WithTimeout(ctx,time.Second*5)
387387
defercancel()
388388

389-
errCh:=make(chanerror)
389+
errCh:=make(chanerror,1)
390390
gofunc() {
391+
deferclose(errCh)
392+
391393
varresDialChannelResponse
392394
err=json.NewDecoder(rw).Decode(&res)
393395
iferr!=nil {
394396
errCh<-fmt.Errorf("read dial response: %w",err)
395397
return
396398
}
399+
397400
d.log.Debug(ctx,"dial response",slog.F("res",res))
398401
ifres.Err=="" {
399-
close(errCh)
400402
return
401403
}
404+
402405
err:=errors.New(res.Err)
403406
ifres.Code==CodeDialErr {
404407
err=&net.OpError{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp