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

Commita778c5f

Browse files
authored
Ensure rtc conn is closed on error (#438)
1 parent4c89550 commita778c5f

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"
@@ -112,6 +113,11 @@ func Dial(ctx context.Context, conn net.Conn, options *DialOptions) (*Dialer, er
112113
iceServers:rtc.GetConfiguration().ICEServers,
113114
rtc:rtc.ConnectionState(),
114115
}
116+
117+
closeErr:=rtc.Close()
118+
ifcloseErr!=nil {
119+
log.Warn(context.Background(),"close rtc connection on dial failure",slog.Error(closeErr))
120+
}
115121
}
116122
}()
117123

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

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

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp