Skip to content

Commit

Permalink
quicreuse: remove workaround for quic-go listener close deadlock (#2746)
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt authored Mar 22, 2024
1 parent 9d149fa commit f12c3ce
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions p2p/transport/quicreuse/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type protoConf struct {

type quicListener struct {
l *quic.Listener
closeMx sync.Mutex
transport refCountedQuicTransport
running chan struct{}
addrs []ma.Multiaddr
Expand Down Expand Up @@ -125,13 +124,7 @@ func (l *quicListener) Add(tlsConf *tls.Config, allowWindowIncrease func(conn qu

func (l *quicListener) Run() error {
defer close(l.running)
defer func() {
// transport close is not safe to use concurrently with listener close.
// remove after https://github.com/quic-go/quic-go/issues/4266 is fixed.
l.closeMx.Lock()
defer l.closeMx.Unlock()
l.transport.DecreaseCount()
}()
defer l.transport.DecreaseCount()
for {
conn, err := l.l.Accept(context.Background())
if err != nil {
Expand All @@ -154,12 +147,7 @@ func (l *quicListener) Run() error {
}

func (l *quicListener) Close() error {
// listener close is not safe to use concurrently with transport close.
// remove after https://github.com/quic-go/quic-go/issues/4266 is fixed.
l.closeMx.Lock()
err := l.l.Close()
l.closeMx.Unlock()

<-l.running // wait for Run to return
return err
}
Expand Down

0 comments on commit f12c3ce

Please sign in to comment.