Skip to content

fix: Guard against conn leak after server close - #1

Closed
mafredri wants to merge 1 commit into
masterfrom
mafredri/fix-conn-leak-after-close
Closed

mafredri wants to merge 1 commit into
masterfrom
mafredri/fix-conn-leak-after-close

Conversation

@mafredri

@mafredri mafredri commented Apr 4, 2023

Copy link
Copy Markdown
Member

Noticed this leak as part of coder/coder#7004

See: https://github.com/coder/coder/actions/runs/4609297757/jobs/8146257114?pr=7004

NOTE: This is mainly a problem when using Serve, which we were not previously using in coder. However, our previous implementation of starting multiple goroutines for each connection were not ideal either. This fix + usage of Serve should reduce overhead/memory usage when there are many connections.

We will also be looking to refactor the implementation as part of coder/coder#6177.

Comment thread server_test.go
}
}

func TestServerClose_ConnectionLeak(t *testing.T) {

@mafredri mafredri Apr 4, 2023 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This test is a bit finicky, but without the fix it will usually time out (as a proof of the issue being fixed).

@mafredri
mafredri marked this pull request as ready for review April 4, 2023 17:51
@mafredri mafredri self-assigned this Apr 4, 2023
@mafredri
mafredri requested review from coadler and kylecarbs April 4, 2023 17:51
@mtojek

mtojek commented May 12, 2023

Copy link
Copy Markdown
Member

Hey @mafredri! Is this PR still valid?

@mafredri

Copy link
Copy Markdown
Member Author

@mtojek It doesn't necessarily hurt but it's not needed anymore, this was fixed in another way in the agentssh package.

Ultimately a more invasive reactor would be better here e.g. if we wanted to contribute it upstream.

@mtojek

mtojek commented May 12, 2023

Copy link
Copy Markdown
Member

Thank you for the quick reply and explanation! I will resolve this one.

@mtojek mtojek closed this May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants