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

quicreuse: remove workaround for quic-go listener close deadlock #2746

Merged
merged 1 commit into from
Mar 22, 2024
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
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
Loading