Skip to content

Commit 55a9df9

Browse files
authored
🐛 [parallelisation] Clean cancel function store after functions have been cancelled (#648)
<!-- Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved. SPDX-License-Identifier: Apache-2.0 --> ### Description - fix a bug about the cancel function store which only grows even if not needed ### Test Coverage <!-- Please put an `x` in the correct box e.g. `[x]` to indicate the testing coverage of this change. --> - [x] This change is covered by existing or additional automated tests. - [ ] Manual testing has been performed (and evidence provided) as automated testing was not feasible. - [ ] Additional tests are not required for this change (e.g. documentation update).
1 parent 82337b3 commit 55a9df9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

changes/20250710210822.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:bug: `[parallelisation]` Clean cancel function store after functions have been cancelled

utils/parallelisation/cancel_functions.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ func (s *CancelFunctionStore) RegisterCancelFunction(cancel ...context.CancelFun
2323
}
2424

2525
func (s *CancelFunctionStore) Cancel() {
26-
defer s.mu.RUnlock()
27-
s.mu.RLock()
26+
defer s.mu.Unlock()
27+
s.mu.Lock()
2828
for _, c := range s.cancelFunctions {
2929
c()
3030
}
31+
s.cancelFunctions = []context.CancelFunc{}
3132
}
3233

3334
func (s *CancelFunctionStore) Len() int {

0 commit comments

Comments
 (0)