forked from Silverfish/proton-bridge
Other: Fix goroutine leaks in sync tests
Add missing Close calls. Properly handle nil channel for `user.startSync`. This patch also updated liteapi and Gluon to latest master and dev version respectively.
This commit is contained in:
committed by
James Houlahan
parent
6fdc8bd379
commit
6bbaf03f1f
@ -94,21 +94,19 @@ func getAddrID(apiAddrs []liteapi.Address, email string) (string, error) {
|
||||
}
|
||||
|
||||
// contextWithStopCh returns a new context that is cancelled when the stop channel is closed or a value is sent to it.
|
||||
func contextWithStopCh(ctx context.Context, stopCh ...<-chan struct{}) (context.Context, context.CancelFunc) {
|
||||
func contextWithStopCh(ctx context.Context, channels ...<-chan struct{}) (context.Context, context.CancelFunc) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
|
||||
for _, stopCh := range stopCh {
|
||||
stopCh := stopCh
|
||||
|
||||
go func() {
|
||||
for _, stopCh := range channels {
|
||||
go func(ch <-chan struct{}) {
|
||||
select {
|
||||
case <-stopCh:
|
||||
case <-ch:
|
||||
cancel()
|
||||
|
||||
case <-ctx.Done():
|
||||
// ...
|
||||
}
|
||||
}()
|
||||
}(stopCh)
|
||||
}
|
||||
|
||||
return ctx, cancel
|
||||
|
||||
Reference in New Issue
Block a user