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

Commite593a44

Browse files
committed
actually close connections properly
1 parent4516e54 commite593a44

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

‎support/support.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"context"
66
"encoding/base64"
77
"encoding/json"
8-
"errors"
98
"io"
109
"net/http"
1110
"strings"
@@ -476,34 +475,23 @@ func sanitizeEnv(kvs map[string]string) {
476475

477476
// TODO: use rpty instead? which is less liable to fail?
478477
funcrunCmd(ctx context.Context,client*codersdk.Client,agentID uuid.UUID,cmdstring) ([]byte,error) {
479-
varerrerror
480-
varclosers []func()error
481-
deferfunc() {
482-
iferr!=nil {
483-
for_,c:=rangeclosers {
484-
iferr2:=c();err2!=nil {
485-
err=errors.Join(err,err2)
486-
}
487-
}
488-
}
489-
}()
490478
agentConn,err:=client.DialWorkspaceAgent(ctx,agentID,&codersdk.DialWorkspaceAgentOptions{})
491479
iferr!=nil {
492480
returnnil,xerrors.Errorf("dial workspace agent: %w",err)
493481
}
494-
closers=append(closers,agentConn.Close)
482+
deferagentConn.Close()
495483

496484
sshClient,err:=agentConn.SSHClient(ctx)
497485
iferr!=nil {
498486
returnnil,xerrors.Errorf("get ssh client: %w",err)
499487
}
500-
closers=append(closers,sshClient.Close)
488+
defersshClient.Close()
501489

502490
sshSession,err:=sshClient.NewSession()
503491
iferr!=nil {
504492
returnnil,xerrors.Errorf("new ssh session: %w",err)
505493
}
506-
closers=append(closers,sshSession.Close)
494+
defersshSession.Close()
507495

508496
cmdBytes,err:=sshSession.CombinedOutput(cmd)
509497
iferr!=nil {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp