Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
09433847
Commit
09433847
authored
Jul 05, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0eba9861
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
10 deletions
+15
-10
wcfs/wcfs.go
wcfs/wcfs.go
+14
-10
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+1
-0
No files found.
wcfs/wcfs.go
View file @
09433847
...
@@ -432,8 +432,8 @@ package main
...
@@ -432,8 +432,8 @@ package main
// zheadMu > Watch.atMu
// zheadMu > Watch.atMu
//
//
// WatchLink.byfileMu > Watch.atMu
// WatchLink.byfileMu > Watch.atMu
// BigFile.watchMu > Watch.atMu
// WatchLink.byfileMu > BigFileDir.fileMu
// WatchLink.byfileMu > BigFileDir.fileMu
// BigFile.watchMu > Watch.atMu
import
(
import
(
"bufio"
"bufio"
...
@@ -605,7 +605,7 @@ type WatchNode struct {
...
@@ -605,7 +605,7 @@ type WatchNode struct {
idNext
int32
// ID for next opened WatchLink
idNext
int32
// ID for next opened WatchLink
}
}
// /head/watch
handle
- served by WatchLink.
// /head/watch
open
- served by WatchLink.
type
WatchLink
struct
{
type
WatchLink
struct
{
sk
*
FileSock
// IO channel to client
sk
*
FileSock
// IO channel to client
id
int32
// ID of this /head/watch handle (for debug log)
id
int32
// ID of this /head/watch handle (for debug log)
...
@@ -615,7 +615,6 @@ type WatchLink struct {
...
@@ -615,7 +615,6 @@ type WatchLink struct {
//
//
// both already established, and watches being initialized in-progress are registered here.
// both already established, and watches being initialized in-progress are registered here.
// (see setupWatch)
// (see setupWatch)
// XXX byfile -> wlink-global watchMu ?
byfileMu
sync
.
Mutex
// zheadMu.W | zheadMu.R + byfileMu (XXX recheck)
byfileMu
sync
.
Mutex
// zheadMu.W | zheadMu.R + byfileMu (XXX recheck)
byfile
map
[
zodb
.
Oid
]
*
Watch
// {} foid -> Watch
byfile
map
[
zodb
.
Oid
]
*
Watch
// {} foid -> Watch
...
@@ -1509,14 +1508,17 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
...
@@ -1509,14 +1508,17 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
headAt
,
headAt
.
Time
()
.
Sub
(
at
.
Time
()
.
Time
))
headAt
,
headAt
.
Time
()
.
Sub
(
at
.
Time
()
.
Time
))
}
}
wlink
.
byfileMu
.
Lock
()
// if watch was already established - we need to update it
// if watch was already established - we need to update it
w
:=
wlink
.
byfile
[
foid
]
// XXX locking
w
:=
wlink
.
byfile
[
foid
]
if
w
==
nil
{
if
w
==
nil
{
// watch was not previously established - set it up anew
// watch was not previously established - set it up anew
bfdir
.
fileMu
.
Lock
()
bfdir
.
fileMu
.
Lock
()
f
:=
bfdir
.
fileTab
[
foid
]
f
:=
bfdir
.
fileTab
[
foid
]
bfdir
.
fileMu
.
Unlock
()
bfdir
.
fileMu
.
Unlock
()
if
f
==
nil
{
if
f
==
nil
{
wlink
.
byfileMu
.
Unlock
()
// by "invalidation protocol" watch is setup after data file was opened
// by "invalidation protocol" watch is setup after data file was opened
return
fmt
.
Errorf
(
"file not yet known to wcfs or is not a ZBigFile"
)
return
fmt
.
Errorf
(
"file not yet known to wcfs or is not a ZBigFile"
)
}
}
...
@@ -1534,9 +1536,10 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
...
@@ -1534,9 +1536,10 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
// at="-" (InvalidTid) means "remove the watch"
// at="-" (InvalidTid) means "remove the watch"
if
at
==
zodb
.
InvalidTid
{
if
at
==
zodb
.
InvalidTid
{
delete
(
wlink
.
byfile
,
foid
)
// XXX locking
delete
(
wlink
.
byfile
,
foid
)
delete
(
f
.
watchTab
,
w
)
delete
(
f
.
watchTab
,
w
)
f
.
watchMu
.
Unlock
()
f
.
watchMu
.
Unlock
()
wlink
.
byfileMu
.
Unlock
()
return
nil
return
nil
}
}
...
@@ -1551,6 +1554,7 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
...
@@ -1551,6 +1554,7 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
if
!
(
at
>=
w
.
at
)
{
if
!
(
at
>=
w
.
at
)
{
w
.
atMu
.
Unlock
()
w
.
atMu
.
Unlock
()
f
.
watchMu
.
Unlock
()
f
.
watchMu
.
Unlock
()
wlink
.
byfileMu
.
Unlock
()
return
fmt
.
Errorf
(
"going back in history is forbidden"
)
return
fmt
.
Errorf
(
"going back in history is forbidden"
)
}
}
...
@@ -1590,13 +1594,11 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
...
@@ -1590,13 +1594,11 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
//
//
// - also: there won't be simultaneous READs that would need to be
// - also: there won't be simultaneous READs that would need to be
// unpinned, because we update w.at to requested at early.
// unpinned, because we update w.at to requested at early.
//
// XXX register only if watch was created anew, not updated?
w
.
at
=
at
w
.
at
=
at
// NOTE registering f.watchTab[w] and wlink.byfile[foid] = w must come together.
f
.
watchTab
[
w
]
=
struct
{}{}
f
.
watchTab
[
w
]
=
struct
{}{}
wlink
.
byfile
[
foid
]
=
w
// XXX locking
wlink
.
byfile
[
foid
]
=
w
f
.
watchMu
.
Unlock
()
f
.
watchMu
.
Unlock
()
wlink
.
byfileMu
.
Unlock
()
// XXX defer -> unregister watch if error?
// XXX defer -> unregister watch if error?
...
@@ -1715,12 +1717,14 @@ func (wlink *WatchLink) _serve() (err error) {
...
@@ -1715,12 +1717,14 @@ func (wlink *WatchLink) _serve() (err error) {
}
}
// unregister all watches created on this wlink
// unregister all watches created on this wlink
for
_
,
w
:=
range
wlink
.
byfile
{
// XXX locking
wlink
.
byfileMu
.
Lock
()
for
_
,
w
:=
range
wlink
.
byfile
{
w
.
file
.
watchMu
.
Lock
()
w
.
file
.
watchMu
.
Lock
()
delete
(
w
.
file
.
watchTab
,
w
)
delete
(
w
.
file
.
watchTab
,
w
)
w
.
file
.
watchMu
.
Unlock
()
w
.
file
.
watchMu
.
Unlock
()
}
}
wlink
.
byfile
=
nil
wlink
.
byfile
=
nil
wlink
.
byfileMu
.
Unlock
()
// write to peer if it was logical error on client side
// write to peer if it was logical error on client side
// then .sk.tx to wakeup rx on client side
// then .sk.tx to wakeup rx on client side
...
...
wcfs/wcfs_test.py
View file @
09433847
...
@@ -2057,6 +2057,7 @@ def procwait_(ctx, proc): # -> ok
...
@@ -2057,6 +2057,7 @@ def procwait_(ctx, proc): # -> ok
raise
raise
return
True
return
True
# xdefer is like defer, but makes sure exception raised before deferred
# xdefer is like defer, but makes sure exception raised before deferred
# function is called is not lost.
# function is called is not lost.
#
#
...
...
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