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: fix stalled virtual listener #2122

Merged
merged 3 commits into from
Feb 22, 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
24 changes: 17 additions & 7 deletions p2p/transport/quic/virtuallistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,23 @@ func (r *acceptLoopRunner) innerAccept(l *listener, expectedVersion quic.Version

func (r *acceptLoopRunner) Accept(l *listener, expectedVersion quic.VersionNumber, bufferedConnChan chan acceptVal) (tpt.CapableConn, error) {
for {
r.acceptSem <- struct{}{}
conn, err := r.innerAccept(l, expectedVersion, bufferedConnChan)
<-r.acceptSem

if conn == nil && err == nil {
// Didn't find a conn for the expected version and there was no error, lets try again
continue
var conn tpt.CapableConn
var err error
select {
case r.acceptSem <- struct{}{}:
conn, err = r.innerAccept(l, expectedVersion, bufferedConnChan)
<-r.acceptSem
MarcoPolo marked this conversation as resolved.
Show resolved Hide resolved

if conn == nil && err == nil {
// Didn't find a conn for the expected version and there was no error, lets try again
continue
}
case v, ok := <-bufferedConnChan:
if !ok {
return nil, errors.New("listener closed")
}
conn = v.conn
err = v.err
}
return conn, err
}
Expand Down