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-ds-flatfs
Commits
0043f364
Commit
0043f364
authored
Mar 26, 2018
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanups and bug fixes.
parent
44965133
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
10 deletions
+8
-10
flatfs.go
flatfs.go
+8
-10
No files found.
flatfs.go
View file @
0043f364
...
...
@@ -109,8 +109,8 @@ type Datastore struct {
dirty
bool
storedValue
diskUsageValue
checkpointCh
chan
bool
done
chan
bool
checkpointCh
chan
struct
{}
done
chan
struct
{}
// opMap handles concurrent write operations (put/delete)
// to the same key
...
...
@@ -243,11 +243,9 @@ func Open(path string, syncFiles bool) (*Datastore, error) {
return
nil
,
err
}
fs
.
checkpointCh
=
make
(
chan
bool
,
1
)
fs
.
done
=
make
(
chan
bool
)
go
func
()
{
fs
.
checkpointLoop
()
}()
fs
.
checkpointCh
=
make
(
chan
struct
{},
1
)
fs
.
done
=
make
(
chan
struct
{})
go
fs
.
checkpointLoop
()
return
fs
,
nil
}
...
...
@@ -797,7 +795,7 @@ func (fs *Datastore) updateDiskUsage(path string, add bool) {
func
(
fs
*
Datastore
)
checkpointDiskUsage
()
{
select
{
case
fs
.
checkpointCh
<-
tru
e
:
case
fs
.
checkpointCh
<-
s
tru
ct
{}{}
:
// msg sent
default
:
// checkpoint request already pending
...
...
@@ -818,7 +816,7 @@ func (fs *Datastore) checkpointLoop() {
if
fs
.
dirty
{
log
.
Errorf
(
"could not store final value of disk usage to file, future estimates may be inaccurate"
)
}
fs
.
done
<-
tru
e
fs
.
done
<-
s
tru
ct
{}{}
return
}
// If the difference between the checkpointed disk usage and
...
...
@@ -834,6 +832,7 @@ func (fs *Datastore) checkpointLoop() {
// `diskUsageCheckpointTimeout`
if
fs
.
dirty
&&
!
timerActive
{
timer
.
Reset
(
diskUsageCheckpointTimeout
)
timerActive
=
true
}
case
<-
timer
.
C
:
timerActive
=
false
...
...
@@ -961,7 +960,6 @@ func (fs *Datastore) walk(path string, reschan chan query.Result) error {
// function
func
(
fs
*
Datastore
)
deactivate
()
error
{
if
fs
.
checkpointCh
!=
nil
{
fs
.
checkpointCh
<-
true
close
(
fs
.
checkpointCh
)
<-
fs
.
done
fs
.
checkpointCh
=
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