Skip to content

Commit

Permalink
quic: fix stalled virtual listener (#2122)
Browse files Browse the repository at this point in the history
* quic: Fix stalled listener

* Undo time fix

* Move check inside case
  • Loading branch information
MarcoPolo authored Feb 22, 2023
1 parent b2f1199 commit a8b1d51
Showing 1 changed file with 17 additions and 7 deletions.
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

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

0 comments on commit a8b1d51

Please sign in to comment.