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

RFC, derp/derphttp: Avoid redundand reconnects. #264

Closed
wants to merge 1 commit into from

Conversation

stablebits
Copy link

@stablebits stablebits commented Apr 6, 2020

  1. closeForReconnect() may be closing already reestablished
    connections. In the worst case, Send() and Recv(), running in
    concurrent loops, would be running connect() and closeForReconnect()
    calls in lockstep endlessly.
  2. Reconnecting doesn't seem to make sense for non-networking errors
    (or at least not for all). e.g. derphttp.Client.Send() may fail
    with "packet too big", which is a local issue.

Signed-off-by: Dmitry Adamushko da@stablebits.net

P.S. Not tested locally.


This change is Reviewable

1. closeForReconnect() may be closing already reestablished
connections. In the worst case, Send() and Recv(), running in
concurrent loops, would be running connect() and closeForReconnect()
calls in lockstep endlessly.
2. Reconnecting doesn't seem to make sense for non-networking errors
(or at least not for all). e.g. derphttp.Client.Send() may fail
with "packet too big", which is a local issue.

Signed-off-by: Dmitry Adamushko <da@stablebits.net>
@@ -234,13 +234,27 @@ func (c *Client) connect(ctx context.Context, caller string) (client *derp.Clien
return c.client, nil
}

func reconnectRequired(err error) bool {
Copy link
Author

@stablebits stablebits Apr 9, 2020

Choose a reason for hiding this comment

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

derp.Client methods could also return something like ErrUnusableTransport to indicate cases that require reconnecting (as opposed to cases when the current transport remains usable). The use of raw networking errors here is insufficient. Perhaps the error handling case should be addressed separately.

bradfitz added a commit that referenced this pull request Apr 11, 2020
@bradfitz
Copy link
Member

@stablebits, I pushed 614eec1 which is the minimal version you'd proposed earlier. I'm not sure I want to get into the business of classifying errors at the moment. I think just saying any error means to give up on the client is enough for now.

@stablebits stablebits closed this Apr 12, 2020
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.

None yet

2 participants