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
ld
go-car
Commits
c06b4f2f
Commit
c06b4f2f
authored
Jul 16, 2021
by
Daniel Martí
Committed by
Masih H. Derkani
Jul 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make Close safe, not letting Finalize block forever either
parent
ae4ddd41
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
v2/blockstore/readonly.go
v2/blockstore/readonly.go
+11
-0
v2/blockstore/readwrite.go
v2/blockstore/readwrite.go
+6
-1
No files found.
v2/blockstore/readonly.go
View file @
c06b4f2f
...
...
@@ -330,7 +330,18 @@ func (b *ReadOnly) Roots() ([]cid.Cid, error) {
}
// Close closes the underlying reader if it was opened by OpenReadOnly.
//
// Note that this call may block if any blockstore operations are currently in
// progress, including an AllKeysChan that hasn't been fully consumed or
// cancelled.
func
(
b
*
ReadOnly
)
Close
()
error
{
b
.
mu
.
Lock
()
defer
b
.
mu
.
Unlock
()
return
b
.
closeWithoutMutex
()
}
func
(
b
*
ReadOnly
)
closeWithoutMutex
()
error
{
if
b
.
carv2Closer
!=
nil
{
return
b
.
carv2Closer
.
Close
()
}
...
...
v2/blockstore/readwrite.go
View file @
c06b4f2f
...
...
@@ -343,7 +343,12 @@ func (b *ReadWrite) Finalize() error {
defer
b
.
mu
.
Unlock
()
// TODO check if add index option is set and don't write the index then set index offset to zero.
b
.
header
=
b
.
header
.
WithDataSize
(
uint64
(
b
.
dataWriter
.
Position
()))
defer
b
.
Close
()
// Note that we can't use b.Close here, as that tries to grab the same
// mutex we're holding here.
// TODO: should we check the error here? especially with OpenReadWrite,
// we should care about close errors.
defer
b
.
closeWithoutMutex
()
// TODO if index not needed don't bother flattening it.
fi
,
err
:=
b
.
idx
.
flatten
()
...
...
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