Skip to content

Commit

Permalink
fix context leak in timeout chain element
Browse files Browse the repository at this point in the history
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik committed Oct 14, 2024
1 parent 76b397f commit f92374e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/networkservice/common/timeout/server.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2020-2021 Doc.ai and/or its affiliates.
//
// Copyright (c) 2020-2023 Cisco Systems, Inc.
// Copyright (c) 2020-2024 Cisco Systems, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -77,10 +77,11 @@ func (s *timeoutServer) Request(ctx context.Context, request *networkservice.Net
afterCh := timeClock.After(timeClock.Until(expirationTime) - requestTimeout)

go func(cancelCtx context.Context, afterCh <-chan time.Time) {
defer cancel()
select {
case <-cancelCtx.Done():
case <-afterCh:
eventFactory.Close(begin.CancelContext(cancelCtx))
<-eventFactory.Close(begin.CancelContext(cancelCtx))
}
}(cancelCtx, afterCh)

Expand Down

0 comments on commit f92374e

Please sign in to comment.