Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
99628170
Unverified
Commit
99628170
authored
Sep 14, 2018
by
Steven Allen
Committed by
GitHub
Sep 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5453 from overbool/fix/pin/goroutine-leaks
fix(pin): goroutine leaks
parents
e4d8360d
996691b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
9 deletions
+42
-9
pin/gc/gc.go
pin/gc/gc.go
+42
-9
No files found.
pin/gc/gc.go
View file @
99628170
...
...
@@ -58,7 +58,10 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn
gcs
,
err
:=
ColoredSet
(
ctx
,
pn
,
ds
,
bestEffortRoots
,
output
)
if
err
!=
nil
{
output
<-
Result
{
Error
:
err
}
select
{
case
output
<-
Result
{
Error
:
err
}
:
case
<-
ctx
.
Done
()
:
}
return
}
emark
.
Append
(
logging
.
LoggableMap
{
...
...
@@ -69,7 +72,10 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn
keychan
,
err
:=
bs
.
AllKeysChan
(
ctx
)
if
err
!=
nil
{
output
<-
Result
{
Error
:
err
}
select
{
case
output
<-
Result
{
Error
:
err
}
:
case
<-
ctx
.
Done
()
:
}
return
}
...
...
@@ -108,7 +114,11 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn
})
esweep
.
Done
()
if
errors
{
output
<-
Result
{
Error
:
ErrCannotDeleteSomeBlocks
}
select
{
case
output
<-
Result
{
Error
:
ErrCannotDeleteSomeBlocks
}
:
case
<-
ctx
.
Done
()
:
return
}
}
defer
log
.
EventBegin
(
ctx
,
"GC.datastore"
)
.
Done
()
...
...
@@ -119,7 +129,10 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn
err
=
gds
.
CollectGarbage
()
if
err
!=
nil
{
output
<-
Result
{
Error
:
err
}
select
{
case
output
<-
Result
{
Error
:
err
}
:
case
<-
ctx
.
Done
()
:
}
return
}
}()
...
...
@@ -177,28 +190,44 @@ func ColoredSet(ctx context.Context, pn pin.Pinner, ng ipld.NodeGetter, bestEffo
links
,
err
:=
ipld
.
GetLinks
(
ctx
,
ng
,
cid
)
if
err
!=
nil
{
errors
=
true
output
<-
Result
{
Error
:
&
CannotFetchLinksError
{
cid
,
err
}}
select
{
case
output
<-
Result
{
Error
:
&
CannotFetchLinksError
{
cid
,
err
}}
:
case
<-
ctx
.
Done
()
:
return
nil
,
ctx
.
Err
()
}
}
return
links
,
nil
}
err
:=
Descendants
(
ctx
,
getLinks
,
gcs
,
pn
.
RecursiveKeys
())
if
err
!=
nil
{
errors
=
true
output
<-
Result
{
Error
:
err
}
select
{
case
output
<-
Result
{
Error
:
err
}
:
case
<-
ctx
.
Done
()
:
return
nil
,
ctx
.
Err
()
}
}
bestEffortGetLinks
:=
func
(
ctx
context
.
Context
,
cid
cid
.
Cid
)
([]
*
ipld
.
Link
,
error
)
{
links
,
err
:=
ipld
.
GetLinks
(
ctx
,
ng
,
cid
)
if
err
!=
nil
&&
err
!=
ipld
.
ErrNotFound
{
errors
=
true
output
<-
Result
{
Error
:
&
CannotFetchLinksError
{
cid
,
err
}}
select
{
case
output
<-
Result
{
Error
:
&
CannotFetchLinksError
{
cid
,
err
}}
:
case
<-
ctx
.
Done
()
:
return
nil
,
ctx
.
Err
()
}
}
return
links
,
nil
}
err
=
Descendants
(
ctx
,
bestEffortGetLinks
,
gcs
,
bestEffortRoots
)
if
err
!=
nil
{
errors
=
true
output
<-
Result
{
Error
:
err
}
select
{
case
output
<-
Result
{
Error
:
err
}
:
case
<-
ctx
.
Done
()
:
return
nil
,
ctx
.
Err
()
}
}
for
_
,
k
:=
range
pn
.
DirectKeys
()
{
...
...
@@ -208,7 +237,11 @@ func ColoredSet(ctx context.Context, pn pin.Pinner, ng ipld.NodeGetter, bestEffo
err
=
Descendants
(
ctx
,
getLinks
,
gcs
,
pn
.
InternalPins
())
if
err
!=
nil
{
errors
=
true
output
<-
Result
{
Error
:
err
}
select
{
case
output
<-
Result
{
Error
:
err
}
:
case
<-
ctx
.
Done
()
:
return
nil
,
ctx
.
Err
()
}
}
if
errors
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment