mirror of
https://github.com/restic/restic.git
synced 2024-12-22 15:57:07 +00:00
Merge pull request #1399 from armhold/deadlock2
prevent deadlock in List() for B2 when b2.connections=1
This commit is contained in:
commit
f854a41ba9
1 changed files with 2 additions and 3 deletions
|
@ -307,18 +307,17 @@ func (be *b2Backend) List(ctx context.Context, t restic.FileType) <-chan string
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
|
|
||||||
be.sem.GetToken()
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(ch)
|
defer close(ch)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
defer be.sem.ReleaseToken()
|
|
||||||
|
|
||||||
prefix := be.Dirname(restic.Handle{Type: t})
|
prefix := be.Dirname(restic.Handle{Type: t})
|
||||||
cur := &b2.Cursor{Prefix: prefix}
|
cur := &b2.Cursor{Prefix: prefix}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
be.sem.GetToken()
|
||||||
objs, c, err := be.bucket.ListCurrentObjects(ctx, be.listMaxItems, cur)
|
objs, c, err := be.bucket.ListCurrentObjects(ctx, be.listMaxItems, cur)
|
||||||
|
be.sem.ReleaseToken()
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue