Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tcpreuse): handle connection that failed to be sampled #3036

Merged
merged 4 commits into from
Nov 21, 2024

Conversation

aschmahmann
Copy link
Collaborator

There was an oversight here in the error reporting. A test should be added, but also probably this should've been caught by automated tooling (e.g. one of the linters), maybe there are more we should be enabling.

@aschmahmann aschmahmann marked this pull request as draft November 12, 2024 05:04
func identifyConnType(c manet.Conn) (DemultiplexedConnType, manet.Conn, error) {
if err := c.SetReadDeadline(time.Now().Add(identifyConnTimeout)); err != nil {
closeErr := c.Close()
return 0, nil, errors.Join(err, closeErr)
}

s, c, err := sampledconn.PeekBytes(c)
Copy link
Collaborator

Choose a reason for hiding this comment

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

These changes aren't necessary, right? It's also not a peekableConn. It's just a manet.Conn. If you want to rename, i would rename the parameter.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I see. This shadows the c in L53.

@MarcoPolo
Copy link
Collaborator

The issue was that the returned connection may be nil when an error is returned, right?

@MarcoPolo
Copy link
Collaborator

https://github.com/uber-go/nilaway Seems promising, but not sure if it would have caught this issue.

@MarcoPolo MarcoPolo marked this pull request as ready for review November 12, 2024 23:22
@MarcoPolo MarcoPolo merged commit 773bedf into master Nov 21, 2024
11 checks passed
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.

2 participants