Skip to content

Commit

Permalink
fix context leak in timeout chain element (#1681)
Browse files Browse the repository at this point in the history
Signed-off-by: NikitaSkrynnik <[email protected]>
  • Loading branch information
NikitaSkrynnik authored Oct 15, 2024
1 parent 083d4e2 commit 7ebf92e
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 7ebf92e

Please sign in to comment.