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-datastore
Commits
34fcd133
Unverified
Commit
34fcd133
authored
Jan 24, 2018
by
Steven Allen
Committed by
GitHub
Jan 24, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #77 from ipfs/fix/syncds-locks
Fix lock usage in syncmount
parents
897edfb7
82f3d02e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
6 deletions
+3
-6
syncmount/mount.go
syncmount/mount.go
+3
-6
No files found.
syncmount/mount.go
View file @
34fcd133
...
...
@@ -35,14 +35,11 @@ func New(mounts []Mount) *Datastore {
type
Datastore
struct
{
mounts
[]
Mount
lk
sync
.
Mutex
}
var
_
ds
.
Datastore
=
(
*
Datastore
)(
nil
)
func
(
d
*
Datastore
)
lookup
(
key
ds
.
Key
)
(
ds
.
Datastore
,
ds
.
Key
,
ds
.
Key
)
{
d
.
lk
.
Lock
()
defer
d
.
lk
.
Unlock
()
for
_
,
m
:=
range
d
.
mounts
{
if
m
.
Prefix
.
Equal
(
key
)
||
m
.
Prefix
.
IsAncestorOf
(
key
)
{
s
:=
strings
.
TrimPrefix
(
key
.
String
(),
m
.
Prefix
.
String
())
...
...
@@ -64,9 +61,6 @@ func (d *Datastore) lookup(key ds.Key) (ds.Datastore, ds.Key, ds.Key) {
// /ao/e/uh/ A /
// /aoe/ not matching
func
(
d
*
Datastore
)
lookupAll
(
key
ds
.
Key
)
(
dst
[]
ds
.
Datastore
,
mountpoint
,
rest
[]
ds
.
Key
)
{
d
.
lk
.
Lock
()
defer
d
.
lk
.
Unlock
()
for
_
,
m
:=
range
d
.
mounts
{
p
:=
m
.
Prefix
.
String
()
if
len
(
p
)
>
1
{
...
...
@@ -257,6 +251,9 @@ func (mt *mountBatch) Delete(key ds.Key) error {
}
func
(
mt
*
mountBatch
)
Commit
()
error
{
mt
.
lk
.
Lock
()
defer
mt
.
lk
.
Unlock
()
for
_
,
t
:=
range
mt
.
mounts
{
err
:=
t
.
Commit
()
if
err
!=
nil
{
...
...
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