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

Commit177839f

Browse files
committed
Ensure rtc conn is closed on error (#438)
(cherry picked from commita778c5f)(cherry picked from commit677577f)
1 parent2954cab commit177839f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

‎wsnet/dial.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/pion/datachannel"
1515
"github.com/pion/webrtc/v3"
1616
"golang.org/x/net/proxy"
17+
"golang.org/x/xerrors"
1718
"nhooyr.io/websocket"
1819

1920
"cdr.dev/slog"
@@ -111,6 +112,11 @@ func Dial(ctx context.Context, conn net.Conn, options *DialOptions) (*Dialer, er
111112
iceServers:rtc.GetConfiguration().ICEServers,
112113
rtc:rtc.ConnectionState(),
113114
}
115+
116+
closeErr:=rtc.Close()
117+
ifcloseErr!=nil {
118+
log.Warn(context.Background(),"close rtc connection on dial failure",slog.Error(closeErr))
119+
}
114120
}
115121
}()
116122

@@ -169,9 +175,12 @@ func Dial(ctx context.Context, conn net.Conn, options *DialOptions) (*Dialer, er
169175
connClosers: []io.Closer{ctrl},
170176
}
171177

172-
// This is on a separate line so the defer above catches it.
173178
err=dialer.negotiate(ctx)
174-
returndialer,err
179+
iferr!=nil {
180+
returnnil,xerrors.Errorf("negotiate rtc connection: %w",err)
181+
}
182+
183+
returndialer,nil
175184
}
176185

177186
// Dialer enables arbitrary dialing to any network and address

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp