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

fix: use a background context when piping derp connections#6750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kylecarbs merged 1 commit intomainfrombgctxderp
Mar 23, 2023

Conversation

kylecarbs
Copy link
Member

This was causing boatloads of connects to reestablish every time...

See#6746

@kylecarbskylecarbs self-assigned thisMar 23, 2023
@kylecarbskylecarbsforce-pushed thebgctxderp branch 2 times, most recently from105c88f to139f905CompareMarch 23, 2023 14:19
@@ -437,7 +435,7 @@ func (api *API) dialWorkspaceAgentTailnet(r *http.Request, agentID uuid.UUID) (*
defer left.Close()
defer right.Close()
brw := bufio.NewReadWriter(bufio.NewReader(right), bufio.NewWriter(right))
api.DERPServer.Accept(ctx, right, brw,r.RemoteAddr)
api.DERPServer.Accept(ctx, right, brw,"internal")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I wrote this on the previous version of this PR, but I guess the suggestion still applies:


How do we avoid leaks here? Isleft guaranteed to be closed at an appropriate time and propagate toright?

Should we actually doctx, cancel := context.WithCancel(api.ctx) outside here and callcancel() inagentConn.CloseFunc?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ahh, good point! Will fix.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fixed!

@kylecarbskylecarbsforce-pushed thebgctxderp branch 2 times, most recently frome7a63dd to7798533CompareMarch 23, 2023 14:27
Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Approving albeit uncommon use of context.

@@ -414,10 +414,8 @@ func (api *API) workspaceAgentListeningPorts(rw http.ResponseWriter, r *http.Req
httpapi.Write(ctx, rw, http.StatusOK, portsResponse)
}

func (api *API) dialWorkspaceAgentTailnet(r *http.Request, agentID uuid.UUID) (*codersdk.WorkspaceAgentConn, error) {
ctx := r.Context()
func (api *API) dialWorkspaceAgentTailnet(ctx context.Context, agentID uuid.UUID) (*codersdk.WorkspaceAgentConn, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Passing a context to a function that returns something tied to that context is a bit weird and uncommon (think net.Dial, would be awkward if it closed the connection once the context is cancelled).

Not a huge issue, but could trip someone up.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Agreed, I'm going to remove the ctx here now!

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Removed. Give it one last look please just to confirm I didn't do anything wacky!

This was causing boatloads of connects to reestablish every time...See#6746
Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks good!

@kylecarbskylecarbsenabled auto-merge (squash)March 23, 2023 14:39
@kylecarbskylecarbs merged commited9a3b9 intomainMar 23, 2023
@kylecarbskylecarbs deleted the bgctxderp branchMarch 23, 2023 14:54
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMar 23, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri approved these changes

Assignees

@kylecarbskylecarbs

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@kylecarbs@mafredri

[8]ページ先頭

©2009-2025 Movatter.jp