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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
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
// zheadMu > Watch.atMu
//
// WatchLink.byfileMu > Watch.atMu
// BigFile.watchMu > Watch.atMu
// WatchLink.byfileMu > BigFileDir.fileMu
// BigFile.watchMu > Watch.atMu
import
(
"bufio"
...
...
@@ -605,7 +605,7 @@ type WatchNode struct {
idNext
int32
// ID for next opened WatchLink
}
// /head/watch
handle
- served by WatchLink.
// /head/watch
open
- served by WatchLink.
type
WatchLink
struct
{
sk
*
FileSock
// IO channel to client
id
int32
// ID of this /head/watch handle (for debug log)
...
...
@@ -615,7 +615,6 @@ type WatchLink struct {
//
// both already established, and watches being initialized in-progress are registered here.
// (see setupWatch)
// XXX byfile -> wlink-global watchMu ?
byfileMu
sync
.
Mutex
// zheadMu.W | zheadMu.R + byfileMu (XXX recheck)
byfile
map
[
zodb
.
Oid
]
*
Watch
// {} foid -> Watch
...
...
@@ -1509,14 +1508,17 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
headAt
,
headAt
.
Time
()
.
Sub
(
at
.
Time
()
.
Time
))
}
wlink
.
byfileMu
.
Lock
()
// if watch was already established - we need to update it
w
:=
wlink
.
byfile
[
foid
]
// XXX locking
w
:=
wlink
.
byfile
[
foid
]
if
w
==
nil
{
// watch was not previously established - set it up anew
bfdir
.
fileMu
.
Lock
()
f
:=
bfdir
.
fileTab
[
foid
]
bfdir
.
fileMu
.
Unlock
()
if
f
==
nil
{
wlink
.
byfileMu
.
Unlock
()
// 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"
)
}
...
...
@@ -1534,9 +1536,10 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
// at="-" (InvalidTid) means "remove the watch"
if
at
==
zodb
.
InvalidTid
{
delete
(
wlink
.
byfile
,
foid
)
// XXX locking
delete
(
wlink
.
byfile
,
foid
)
delete
(
f
.
watchTab
,
w
)
f
.
watchMu
.
Unlock
()
wlink
.
byfileMu
.
Unlock
()
return
nil
}
...
...
@@ -1551,6 +1554,7 @@ func (wlink *WatchLink) setupWatch(ctx context.Context, foid zodb.Oid, at zodb.T
if
!
(
at
>=
w
.
at
)
{
w
.
atMu
.
Unlock
()
f
.
watchMu
.
Unlock
()
wlink
.
byfileMu
.
Unlock
()
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
//
// - also: there won't be simultaneous READs that would need to be
// unpinned, because we update w.at to requested at early.
//
// XXX register only if watch was created anew, not updated?
w
.
at
=
at
// NOTE registering f.watchTab[w] and wlink.byfile[foid] = w must come together.
f
.
watchTab
[
w
]
=
struct
{}{}
wlink
.
byfile
[
foid
]
=
w
// XXX locking
wlink
.
byfile
[
foid
]
=
w
f
.
watchMu
.
Unlock
()
wlink
.
byfileMu
.
Unlock
()
// XXX defer -> unregister watch if error?
...
...
@@ -1715,12 +1717,14 @@ func (wlink *WatchLink) _serve() (err error) {
}
// 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
()
delete
(
w
.
file
.
watchTab
,
w
)
w
.
file
.
watchMu
.
Unlock
()
}
wlink
.
byfile
=
nil
wlink
.
byfileMu
.
Unlock
()
// write to peer if it was logical error 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
raise
return
True
# xdefer is like defer, but makes sure exception raised before deferred
# 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