Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
4895b218
Commit
4895b218
authored
Jan 13, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
22a4acd4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
15 deletions
+21
-15
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+21
-15
No files found.
go/zodb/storage/fs1/filestorage.go
View file @
4895b218
...
...
@@ -89,7 +89,7 @@ import (
type
FileStorage
struct
{
file
*
os
.
File
// protects updates to index and to txnh{Min,Max} - in other words
//
mu
protects updates to index and to txnh{Min,Max} - in other words
// to everything that depends on what current last transaction is.
// mu also protects downErr.
mu
sync
.
RWMutex
...
...
@@ -500,13 +500,19 @@ func (fs *FileStorage) watcher(w *fsnotify.Watcher, errFirstRead chan<- error) {
}
}
const
watchTrace
=
false
func
traceWatch
(
format
string
,
argv
...
interface
{})
{
if
!
watchTrace
{
return
}
log
.
Printf
(
" fs1: watcher: "
+
format
,
argv
...
)
}
// _watcher serves watcher and returns either when fs is closed (ok), or when
// it hits any kind of non-recoverable error.
func
(
fs
*
FileStorage
)
_watcher
(
w
*
fsnotify
.
Watcher
,
errFirstRead
chan
<-
error
)
(
err
error
)
{
tracef
:=
func
(
format
string
,
argv
...
interface
{})
{
log
.
Printf
(
" fs1: watcher: "
+
format
,
argv
...
)
}
tracef
(
">>>"
)
traceWatch
(
">>>"
)
f
:=
fs
.
file
idx
:=
fs
.
index
...
...
@@ -529,28 +535,28 @@ func (fs *FileStorage) _watcher(w *fsnotify.Watcher, errFirstRead chan<- error)
mainloop
:
for
{
if
!
first
{
trace
f
(
"select ..."
)
trace
Watch
(
"select ..."
)
select
{
case
<-
fs
.
down
:
// closed
trace
f
(
"down"
)
trace
Watch
(
"down"
)
return
nil
case
err
:=
<-
w
.
Errors
:
trace
f
(
"error"
)
trace
Watch
(
"error: %s"
,
err
)
if
err
!=
fsnotify
.
ErrEventOverflow
{
return
err
}
// events lost, but it is safe since we are always rechecking file size
case
<-
w
.
Events
:
case
ev
:=
<-
w
.
Events
:
// we got some kind of "file was modified" event (e.g.
// write, truncate, chown ...) -> it is time to check the file again.
trace
f
(
"event"
)
trace
Watch
(
"event: %s"
,
ev
)
case
<-
tick
.
C
:
// recheck the file periodically.
trace
f
(
"tick"
)
trace
Watch
(
"tick"
)
}
// we will be advancing through the file as much as we can.
...
...
@@ -579,7 +585,7 @@ mainloop:
return
err
}
fsize
:=
fi
.
Size
()
trace
f
(
"toppos: %d
\t
fsize: %d
\n
"
,
idx
.
TopPos
,
fsize
)
trace
Watch
(
"toppos: %d
\t
fsize: %d
\n
"
,
idx
.
TopPos
,
fsize
)
switch
{
case
fsize
==
idx
.
TopPos
:
continue
// same as before
...
...
@@ -590,7 +596,7 @@ mainloop:
// there is some data after toppos - try to advance as much as we can.
// start iterating afresh with new empty buffer.
trace
f
(
"scanning ..."
)
trace
Watch
(
"scanning ..."
)
it
:=
Iterate
(
seqReadAt
(
f
),
idx
.
TopPos
,
IterForward
)
for
{
err
=
it
.
NextTxn
(
LoadNoStrings
)
...
...
@@ -629,7 +635,7 @@ mainloop:
// read ok - reset t₀(partial)
t0partial
=
time
.
Time
{}
trace
f
(
"@%d tid=%s st=%q"
,
it
.
Txnh
.
Pos
,
it
.
Txnh
.
Tid
,
it
.
Txnh
.
Status
)
trace
Watch
(
"@%d tid=%s st=%q"
,
it
.
Txnh
.
Pos
,
it
.
Txnh
.
Tid
,
it
.
Txnh
.
Status
)
if
errFirstRead
!=
nil
{
errFirstRead
<-
nil
// ok
...
...
@@ -676,7 +682,7 @@ mainloop:
}
fs
.
mu
.
Unlock
()
trace
f
(
"-> tid=%s δoidv=%v"
,
it
.
Txnh
.
Tid
,
oidv
)
trace
Watch
(
"-> tid=%s δoidv=%v"
,
it
.
Txnh
.
Tid
,
oidv
)
// notify client
if
fs
.
watchq
!=
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