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
1b4bee0e
Commit
1b4bee0e
authored
Dec 03, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3a755a42
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
33 deletions
+49
-33
wcfs/internal/_wcfs.pyx
wcfs/internal/_wcfs.pyx
+44
-28
wcfs/internal/wcfs.h
wcfs/internal/wcfs.h
+2
-2
wcfs/internal/wcfs_virtmem.cpp
wcfs/internal/wcfs_virtmem.cpp
+3
-3
No files found.
wcfs/internal/_wcfs.pyx
View file @
1b4bee0e
...
...
@@ -39,7 +39,7 @@ cdef extern from *:
from
libc.stdint
cimport
int64_t
,
uint64_t
from
ZODB.utils
import
p64
from
ZODB.utils
import
p64
,
u64
# XXX -> pygolang
cdef
extern
from
"wcfs_misc.h"
namespace
"io"
nogil
:
...
...
@@ -90,6 +90,7 @@ cdef extern from "wcfs.h" nogil:
string
mountpoint
pair
[
WatchLink
,
error
]
_openwatch
()
# XXX pair instead of tuple
pair
[
Conn
,
error
]
connect
(
Tid
at
)
cppclass
_Conn
:
# XXX
...
...
@@ -109,7 +110,27 @@ cdef class PyWCFS:
def
__set__
(
PyWCFS
pywc
,
string
v
):
pywc
.
wc
.
mountpoint
=
v
# XXX connect
def
connect
(
PyWCFS
pywc
,
pyat
):
# -> PyConn
cdef
Tid
at
=
u64
(
pyat
)
with
nogil
:
_
=
pywc
.
wc
.
connect
(
at
)
wconn
=
_
.
first
err
=
_
.
second
if
err
!=
nil
:
raise
pyerr
(
err
)
cdef
PyConn
pywconn
=
PyConn
.
__new__
(
PyConn
)
pywconn
.
wconn
=
wconn
return
pywconn
cdef
class
PyConn
:
cdef
Conn
wconn
def
__dealloc__
(
PyConn
pywconn
):
pywconn
.
wconn
=
nil
cdef
class
PyWatchLink
:
cdef
WatchLink
wlink
...
...
@@ -121,7 +142,7 @@ cdef class PyWatchLink:
err
=
_
.
second
if
err
!=
nil
:
raise
RuntimeError
(
err
.
Error
())
# XXX exc class?
raise
pyerr
(
err
)
def
__dealloc__
(
PyWatchLink
pywlink
):
pywlink
.
wlink
=
nil
...
...
@@ -131,13 +152,13 @@ cdef class PyWatchLink:
with
nogil
:
err
=
wlink_close_pyexc
(
pywlink
.
wlink
)
if
err
!=
nil
:
raise
RuntimeError
(
err
.
Error
())
# XXX exc class?
raise
pyerr
(
err
)
def
closeWrite
(
PyWatchLink
pywlink
):
with
nogil
:
err
=
wlink_closeWrite_pyexc
(
pywlink
.
wlink
)
if
err
!=
nil
:
raise
RuntimeError
(
err
.
Error
())
# XXX exc class?
raise
pyerr
(
err
)
def
sendReq
(
PyWatchLink
pywlink
,
context
.
PyContext
pyctx
,
string
req
):
# -> reply(string)
...
...
@@ -147,13 +168,7 @@ cdef class PyWatchLink:
err
=
_
.
second
if
err
!=
nil
:
# XXX -> common place? support for other errors? is it good idea?
if
err
.
eq
(
context
.
canceled
):
raise
pycontext
.
canceled
if
err
.
eq
(
context
.
deadlineExceeded
):
raise
pycontext
.
deadlineExceeded
raise
RuntimeError
(
err
.
Error
())
# XXX -> Xpy(err) ? pyraiseIf(err) ?
raise
pyerr
(
err
)
return
reply
...
...
@@ -164,15 +179,8 @@ cdef class PyWatchLink:
if
err
.
eq
(
EOF
):
return
None
if
err
!=
nil
:
# XXX -> common place? support for other errors? is it good idea?
if
err
.
eq
(
context
.
canceled
):
raise
pycontext
.
canceled
if
err
.
eq
(
context
.
deadlineExceeded
):
raise
pycontext
.
deadlineExceeded
raise
RuntimeError
(
err
.
Error
())
# XXX exc class?
raise
pyerr
(
err
)
return
pyreq
...
...
@@ -181,13 +189,7 @@ cdef class PyWatchLink:
err
=
wlink_replyReq_pyexc
(
pywlink
.
wlink
,
pyctx
.
ctx
,
&
pyreq
.
pinreq
,
reply
)
if
err
!=
nil
:
# XXX -> common place? support for other errors? is it good idea?
if
err
.
eq
(
context
.
canceled
):
raise
pycontext
.
canceled
if
err
.
eq
(
context
.
deadlineExceeded
):
raise
pycontext
.
deadlineExceeded
raise
RuntimeError
(
err
.
Error
())
# XXX -> Xpy(err) ? pyraiseIf(err) ?
raise
pyerr
(
err
)
return
...
...
@@ -230,10 +232,24 @@ def _tpywlinkwrite(PyWatchLink pywlink, bytes pypkt):
with
nogil
:
err
=
_twlinkwrite_pyexc
(
pywlink
.
wlink
,
pkt
)
if
err
!=
nil
:
raise
RuntimeError
(
err
.
Error
())
# XXX exc class?
raise
pyerr
(
err
)
# ---- misc ----
# pyerr converts error into python error.
cdef
object
pyerr
(
error
err
):
if
err
==
nil
:
return
None
# XXX support for other errors? is it good idea?
if
err
.
eq
(
context
.
canceled
):
return
pycontext
.
canceled
if
err
.
eq
(
context
.
deadlineExceeded
):
return
pycontext
.
deadlineExceeded
return
RuntimeError
(
err
.
Error
())
# XXX exc class ok?
from
golang
cimport
topyexc
cdef
nogil
:
...
...
wcfs/internal/wcfs.h
View file @
1b4bee0e
...
...
@@ -51,7 +51,7 @@ typedef refptr<class _WatchLink> WatchLink;
struct
WCFS
{
string
mountpoint
;
tuple
<
Conn
,
error
>
connect
(
zodb
::
Tid
at
);
pair
<
Conn
,
error
>
connect
(
zodb
::
Tid
at
);
string
_path
(
const
string
&
obj
);
tuple
<
os
::
File
,
error
>
_open
(
const
string
&
path
,
int
flags
=
O_RDONLY
);
pair
<
WatchLink
,
error
>
_openwatch
();
...
...
@@ -85,7 +85,7 @@ struct _Conn : object {
private:
_Conn
();
~
_Conn
();
friend
tuple
<
Conn
,
error
>
WCFS
::
connect
(
zodb
::
Tid
at
);
friend
pair
<
Conn
,
error
>
WCFS
::
connect
(
zodb
::
Tid
at
);
public:
void
decref
();
...
...
wcfs/internal/wcfs_virtmem.cpp
View file @
1b4bee0e
...
...
@@ -88,7 +88,7 @@ struct _Mapping {
// connect creates new Conn viewing WCFS state as of @at.
tuple
<
Conn
,
error
>
WCFS
::
connect
(
zodb
::
Tid
at
)
{
pair
<
Conn
,
error
>
WCFS
::
connect
(
zodb
::
Tid
at
)
{
WCFS
*
wc
=
this
;
// XXX err ctx
...
...
@@ -98,7 +98,7 @@ tuple<Conn, error> WCFS::connect(zodb::Tid at) {
error
err
;
tie
(
wlink
,
err
)
=
wc
->
_openwatch
();
if
(
err
!=
nil
)
return
make_
tuple
(
nil
,
err
);
return
make_
pair
(
nil
,
err
);
Conn
wconn
=
adoptref
(
new
_Conn
());
wconn
->
_wc
=
wc
;
...
...
@@ -113,7 +113,7 @@ tuple<Conn, error> WCFS::connect(zodb::Tid at) {
return
wconn
->
_pinner
(
ctx
);
});
return
make_
tuple
(
wconn
,
nil
);
return
make_
pair
(
wconn
,
nil
);
}
// close releases resources associated with wconn.
...
...
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