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

derp/derphttp: NotePreferred is sent synchronously which causes failures with blocking IO #7557

Open
kylecarbs opened this issue Mar 14, 2023 · 2 comments

Comments

@kylecarbs
Copy link
Contributor

The Recv function in derphttp_client.go is called after client creation which waits for NotePreferred to be sent if applicable.

if c.preferred {
if err := derpClient.NotePreferred(true); err != nil {
go httpConn.Close()
return nil, 0, err
}
}

This becomes problematic when using io.Pipe as a transport because the accept loop in derp_server.go only runs after flushing sendServerKey.

br := brw.Reader
nc.SetDeadline(time.Now().Add(10 * time.Second))
bw := &lazyBufioWriter{w: nc, lbw: brw.Writer}
if err := s.sendServerKey(bw); err != nil {
return fmt.Errorf("send server key: %v", err)
}

It seems like the best course of action is to make NotePreferred run in a goroutine. The current implementation allows for this with a custom dialer, which is only allowed for non-regional clients.

I'll do this but first wanted assurance that there wouldn't be any odd issues I'm overlooking by making this change. If this isn't a problem and I'm mistaken, feel free to close!

@DentonGentry
Copy link
Contributor

I think you're setting up time with one of the engineers here, this might be another topic to discuss.

@DentonGentry
Copy link
Contributor

I guess we should also monitor google/gvisor#6113, putting it here in the bug so we'll see it during the next bug scrub.

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

No branches or pull requests

2 participants