Commit eb1e1798 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4f8b5511
...@@ -33,7 +33,7 @@ using std::pair; ...@@ -33,7 +33,7 @@ using std::pair;
#include "wcfs_misc.h" #include "wcfs_misc.h"
class _Conn; struct _Conn;
class _WatchLink; class _WatchLink;
......
...@@ -66,8 +66,8 @@ struct PinReq; ...@@ -66,8 +66,8 @@ struct PinReq;
// Use .resync to resync Conn onto different database view. // Use .resync to resync Conn onto different database view.
// //
// Conn logically mirrors ZODB.Connection . // Conn logically mirrors ZODB.Connection .
typedef refptr<class _Conn> Conn; typedef refptr<struct _Conn> Conn;
class _Conn { struct _Conn : object {
WCFS *_wc; WCFS *_wc;
zodb::Tid at; zodb::Tid at;
WatchLink _wlink; // watch/receive pins for created mappings WatchLink _wlink; // watch/receive pins for created mappings
...@@ -75,7 +75,8 @@ class _Conn { ...@@ -75,7 +75,8 @@ class _Conn {
sync::Mutex _filemu; sync::Mutex _filemu;
dict<zodb::Oid, _File*> _filetab; // {} foid -> _file dict<zodb::Oid, _File*> _filetab; // {} foid -> _file
// XXX ._pinWG, ._pinCancel sync::WorkGroup _pinWG;
func<void()> _pinCancel;
// don't new - create via WCFS.connect // don't new - create via WCFS.connect
private: private:
...@@ -90,7 +91,7 @@ public: ...@@ -90,7 +91,7 @@ public:
error resync(zodb::Tid at); error resync(zodb::Tid at);
private: private:
void _pinner(context::Context ctx); error _pinner(context::Context ctx);
void _pin1(PinReq *req); void _pin1(PinReq *req);
}; };
...@@ -148,17 +149,20 @@ tuple<Conn, error> WCFS::connect(zodb::Tid at) { ...@@ -148,17 +149,20 @@ tuple<Conn, error> WCFS::connect(zodb::Tid at) {
wconn->_wlink = wlink; wconn->_wlink = wlink;
pinCtx, wconn._pinCancel = context.with_cancel(context.background()) context::Context pinCtx;
wconn._pinWG = sync.WorkGroup(pinCtx) tie(pinCtx, wconn->_pinCancel) = context::with_cancel(context::background());
wconn._pinWG.go(wconn._pinner) wconn->_pinWG = sync::NewWorkGroup(pinCtx);
wconn->_pinWG->go([wconn](context::Context ctx) -> error {
return wconn->_pinner(ctx);
});
return make_tuple(wconn, nil); return make_tuple(wconn, nil);
} }
// close releases resources associated with wconn. // close releases resources associated with wconn.
// XXX what happens to file mmappings? // XXX what happens to file mmappings?
error Conn::close() { // XXX error -> void? error _Conn::close() { // XXX error -> void?
Conn &wconn = *this; _Conn& wconn = *this;
wconn._wlink->close(); // XXX err wconn._wlink->close(); // XXX err
#if 0 #if 0
...@@ -191,8 +195,8 @@ error Conn::close() { // XXX error -> void? ...@@ -191,8 +195,8 @@ error Conn::close() { // XXX error -> void?
} }
// _pinner receives pin messages from wcfs and adjusts wconn mappings. // _pinner receives pin messages from wcfs and adjusts wconn mappings.
void Conn::_pinner(context::Context ctx) { error _Conn::_pinner(context::Context ctx) { // XXX error -> where?
Conn &wconn = *this; _Conn& wconn = *this;
// XXX panic/exc -> log.CRITICAL // XXX panic/exc -> log.CRITICAL
...@@ -203,7 +207,7 @@ void Conn::_pinner(context::Context ctx) { ...@@ -203,7 +207,7 @@ void Conn::_pinner(context::Context ctx) {
err = wconn._wlink->recvReq(ctx, &req); err = wconn._wlink->recvReq(ctx, &req);
if (err != nil) { if (err != nil) {
// XXX -> err, handle EOF, abort on * // XXX -> err, handle EOF, abort on *
return; // XXX ok? (EOF - when wcfs closes wlink) return err; // XXX ok? (EOF - when wcfs closes wlink)
} }
// we received request to pin/unpin file block. handle it // we received request to pin/unpin file block. handle it
...@@ -212,8 +216,8 @@ void Conn::_pinner(context::Context ctx) { ...@@ -212,8 +216,8 @@ void Conn::_pinner(context::Context ctx) {
} }
// pin1 handles one pin request received from wcfs. // pin1 handles one pin request received from wcfs.
void Conn::_pin1(PinReq *req) { void _Conn::_pin1(PinReq *req) {
Conn &wconn = *this; _Conn& wconn = *this;
// XXX defer: reply either ack or nak on error // XXX defer: reply either ack or nak on error
// XXX return error? // XXX return error?
...@@ -264,8 +268,8 @@ void Conn::_pin1(PinReq *req) { ...@@ -264,8 +268,8 @@ void Conn::_pin1(PinReq *req) {
// XXX Conn::mmap // XXX Conn::mmap
// resync resyncs connection and its mappings onto different database view. // resync resyncs connection and its mappings onto different database view.
error Conn::resync(zodb::Tid at) { error _Conn::resync(zodb::Tid at) {
Conn &wconn = *this; _Conn& wconn = *this;
// XXX err ctx // XXX err ctx
// XXX locking // XXX locking
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
# See https://www.nexedi.com/licensing for rationale and options. # See https://www.nexedi.com/licensing for rationale and options.
"""wcfs_test tests wcfs filesystem from outside as python client process """wcfs_test tests wcfs filesystem from outside as python client process
It also unit-tests wcfs.py virtmem-level integration. It also unit-tests wcfs.py virtmem-level integration. XXX
At functional level, the whole wendelin.core test suite is used to verify At functional level, the whole wendelin.core test suite is used to verify
wcfs.py/wcfs.go while running tox tests in wcfs mode. wcfs.py/wcfs.go while running tox tests in wcfs mode.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment