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

quic virtual listener: don't panic when quic-go's accept call errors #2276

Merged
merged 1 commit into from
May 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions p2p/transport/quic/virtuallistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ type acceptVal struct {
type acceptLoopRunner struct {
acceptSem chan struct{}

muxerMu sync.Mutex
muxer map[quic.VersionNumber]chan acceptVal
muxerMu sync.Mutex
muxer map[quic.VersionNumber]chan acceptVal
muxerClosed bool
}

func (r *acceptLoopRunner) AcceptForVersion(v quic.VersionNumber) chan acceptVal {
Expand All @@ -68,6 +69,11 @@ func (r *acceptLoopRunner) RmAcceptForVersion(v quic.VersionNumber) {
r.muxerMu.Lock()
defer r.muxerMu.Unlock()

if r.muxerClosed {
// Already closed, all versions are removed
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this an error-specific closing that basically indicates a failed start? If so maybe document/name it like that.

If so, does this mean that Accept should be modified as well? Want to make sure we don't end up in a position where we can keep calling accept but not RmAccept.

Copy link
Contributor

Choose a reason for hiding this comment

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

We see the situation that quic-go's Accept sometimes errors on Windows machines. It might or might not be related to quic-go/quic-go#1737. I don't have a Windows machine, so I can't really debug this. Also, I care more about other OSes ;)

There should probably be some logging, but I'm fine adding this in a later PR.

return
}

ch, ok := r.muxer[v]
if !ok {
panic("expected chan in accept muxer")
Expand All @@ -79,6 +85,7 @@ func (r *acceptLoopRunner) RmAcceptForVersion(v quic.VersionNumber) {
func (r *acceptLoopRunner) sendErrAndClose(err error) {
r.muxerMu.Lock()
defer r.muxerMu.Unlock()
r.muxerClosed = true
for k, ch := range r.muxer {
select {
case ch <- acceptVal{err: err}:
Expand Down