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:
Leander Beernaert
2022-10-21 13:58:18 +02:00
committed by James Houlahan
parent 6fdc8bd379
commit 6bbaf03f1f
10 changed files with 63 additions and 21 deletions

View File

@ -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