Skip to content

Commit 574e5eb

Browse files
neildgopherbot
authored andcommitted
quic: halt conn goroutines on close when listener exits early
Endpoint.Close could return with conn goroutines still running if the endpoint's PacketConn was closed prior to the last conn exiting. (Normally the last conn to exit closes the PacketConn.) Clean up any stray conns before returning. Change-Id: I444f7dbb1e7b194c74a1ff8025abb4346a6a6964 Reviewed-on: https://go-review.googlesource.com/c/net/+/801881 LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Nicholas Husin <nsh@golang.org> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Nicholas Husin <husin@google.com>
1 parent 0da447f commit 574e5eb

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎quic/endpoint.go‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,11 @@ func (e *Endpoint) Close(ctx context.Context) error {
149149
select {
150150
case <-e.closec:
151151
case <-ctx.Done():
152-
for _, c := range conns {
153-
c.exit()
154-
}
155-
return ctx.Err()
156152
}
157-
return nil
153+
for _, c := range conns {
154+
c.exit()
155+
}
156+
return ctx.Err() // nil if context hasn't expired
158157
}
159158

160159
// Accept waits for and returns the next connection.

0 commit comments

Comments
 (0)