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

rcmgr: *: Always close connscope #2037

Merged
merged 3 commits into from
Feb 1, 2023
Merged

Conversation

MarcoPolo
Copy link
Collaborator

@MarcoPolo MarcoPolo commented Jan 31, 2023

Fixes #2033.

Closes #2025 and closes #2031 .

The general pattern here is replacing

func ...Dial() {
  connScope := ...
  
  err := ...
  if err != nil {
    connScope.Done()
  }
  
    err := ...
  if err != nil {
    connScope.Done()
  }
  
    err := ...
  if err != nil {
    connScope.Done()
  }
}

With:

func ...Dial() {
  connScope := ...
  
  c, err := dialWithScope
  
  if err != nil {
    connScope.Done()
    return nil, err
  }
  
  return c, nil
}

func dialWithScope(..., connScope) {
  if err != nil {
     return nil, err
  }
}

Copy link
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

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

Good idea to fix this class of issues once and for all!

@MarcoPolo MarcoPolo merged commit 753e48e into master Feb 1, 2023
@marten-seemann marten-seemann mentioned this pull request Feb 2, 2023
35 tasks
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.

rcmgr: Finish reservation in one place when connection handshake fails
2 participants