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
4d006d3c
Commit
4d006d3c
authored
Jul 17, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3470a1d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
8 deletions
+27
-8
wcfs/__init__.py
wcfs/__init__.py
+27
-8
No files found.
wcfs/__init__.py
View file @
4d006d3c
...
...
@@ -156,7 +156,7 @@ def close(wconn):
# close all files - both that have no mappings and that still have opened mappings.
# XXX after file is closed mappings continue to survive, but we can no
# longer maint
in consisten
view.
# longer maint
ain consistent
view.
with
wconn
.
_filemu
:
for
f
in
wconn
.
_filetab
.
values
():
f
.
headf
.
close
()
...
...
@@ -249,17 +249,31 @@ def _pin1(wconn, req):
def
resync
(
wconn
,
at
):
# XXX locking
for
foid
in
wconn
.
_filetab
:
for
foid
,
f
in
wconn
.
_filetab
.
items
()
:
# XXX if file has no mappings and was not used during whole prev
# cycle - forget and stop watching it
# update f.headfsize and remmap to head/f zero regions that are now covered by head/f
_
=
os
.
fstat
(
f
.
headf
.
fileno
())
assert
f
.
blksize
==
_
.
st_blksize
# blksize must not change
headfsize
=
_
.
st_size
assert
f
.
headfsize
<=
headfsize
# head/file size ↑=
assert
headfsize
%
f
.
blksize
==
0
for
mmap
in
f
.
mmaps
:
memunzero
=
mmap
.
mem
[
f
.
headfsize
-
mmap
.
blk_start
*
f
.
blksize
:
headfsize
-
mmap
.
blk_start
*
f
.
blksize
]
if
len
(
memunzero
)
>
0
:
mm
.
map_into_ro
(
memunzero
,
f
.
headf
.
fileno
(),
f
.
headfsize
)
f
.
headfsize
=
headfsize
_
=
wconn
.
_wlink
.
sendReq
(
context
.
background
(),
b"watch %s @%s"
%
(
h
(
foid
),
h
(
at
)))
if
_
!=
"ok"
:
# XXX unregister f from _filetab
# XXX vvv -> errctx?
raise
RuntimeError
(
"resync @%s -> @%s: f<%s>: %s"
%
(
h
(
wconn
.
at
),
h
(
at
),
h
(
foid
),
_
))
# XXX update f.headfsize
# XXX remmap appended data after old f.headfsize
wconn
.
at
=
at
...
...
@@ -282,6 +296,7 @@ def mmap(wconn, foid, blk_start, blk_len): # -> Mapping
_
=
os
.
fstat
(
f
.
headf
.
fileno
())
f
.
blksize
=
_
.
st_blksize
f
.
headfsize
=
_
.
st_size
assert
f
.
headfsize
%
f
.
blksize
==
0
wconn
.
_filetab
[
foid
]
=
f
...
...
@@ -323,7 +338,13 @@ def mmap(wconn, foid, blk_start, blk_len): # -> Mapping
def
_remmapblk
(
mmap
,
blk
,
at
):
assert
mmap
.
blk_start
<=
blk
<
mmap
.
blk_stop
f
=
mmap
.
file
blkmem
=
mmap
.
mem
[(
blk
-
mmap
.
blk_start
)
*
f
.
blksize
:][:
f
.
blksize
]
if
at
is
None
:
# head/file[blk >= size] -> Z
if
blk
*
f
.
blksize
>=
f
.
headfsize
:
mm
.
map_zero_into
(
blkmem
)
return
# head/file[blk < size] -> use the file
fsfile
=
f
.
headf
else
:
# TODO share @rev fd until wconn is resynced?
...
...
@@ -331,9 +352,7 @@ def _remmapblk(mmap, blk, at):
defer
(
fsfile
.
close
)
assert
os
.
fstat
(
fsfile
.
fileno
()).
st_blksize
==
f
.
blksize
# FIXME assert
mm
.
map_into_ro
(
mmap
.
mem
[(
blk
-
mmap
.
blk_start
)
*
f
.
blksize
:][:
f
.
blksize
],
fsfile
.
fileno
(),
blk
*
f
.
blksize
)
mm
.
map_into_ro
(
blkmem
,
fsfile
.
fileno
(),
blk
*
f
.
blksize
)
# remmap_blk remmaps file[blk] in its place again.
...
...
@@ -758,7 +777,7 @@ def join(zurl, autostart=_default_autostart()): # -> WCFS
# _start starts wcfs server for ZODB @ zurl.
#
# optv can be optionally given to pass flags to wcfs.
# called under _wcmu
# called under _wcmu
.
def
_start
(
zurl
,
*
optv
):
# -> WCFS
mntpt
=
_mntpt_4zurl
(
zurl
)
log
.
info
(
"wcfs: starting for %s ..."
,
zurl
)
...
...
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