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
d34c4610
Commit
d34c4610
authored
Nov 01, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
09310101
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
575 additions
and
516 deletions
+575
-516
setup.py
setup.py
+1
-0
wcfs/internal/wcfs_misc.h
wcfs/internal/wcfs_misc.h
+64
-1
wcfs/internal/wcfs_virtmem.cpp
wcfs/internal/wcfs_virtmem.cpp
+16
-515
wcfs/internal/wcfs_watchlink.cpp
wcfs/internal/wcfs_watchlink.cpp
+386
-0
wcfs/internal/wcfs_watchlink.h
wcfs/internal/wcfs_watchlink.h
+108
-0
No files found.
setup.py
View file @
d34c4610
...
...
@@ -235,6 +235,7 @@ setup(
PyGoExt
(
'wcfs.internal._wcfs'
,
[
'wcfs/internal/_wcfs.pyx'
,
'wcfs/internal/wcfs_virtmem.cpp'
,
'wcfs/internal/wcfs_watchlink.cpp'
,
'wcfs/internal/wcfs_misc.cpp'
,
],
include_dirs
=
[
# XXX -> common place
...
...
wcfs/internal/wcfs_misc.h
View file @
d34c4610
...
...
@@ -23,6 +23,7 @@
#define _NXD_WCFS_MISC_H_
#include <stddef.h>
#include <stdint.h>
#include <string>
using
std
::
string
;
...
...
@@ -152,6 +153,59 @@ vector<string> split(const string &s, char sep);
}
// strings::
// XXX ok?
struct
IContext
{
virtual
chan
<
structZ
>
done
()
=
0
;
virtual
error
err
()
=
0
;
};
// context::
namespace
context
{
struct
_Background
:
IContext
{
chan
<
structZ
>
done
()
{
return
nil
;
}
error
err
()
{
return
nil
;
}
};
static
_Background
_bg
;
// XXX doc
IContext
*
background
()
{
return
&
_bg
;
// NOTE nil is not valid in C++ (IContext* also carries vtab ptr)
}
// XXX doc
const
error
canceled
=
fmt
::
errorf
(
"context canceled"
);
// XXX deadline exceeded?
}
// context::
#if 0
interface(Context) {
ifunc(chan<structZ> done());
ifunc(error err());
};
I<io::Reader>(f)
// XXX wrap T* as IContext
template<typename T>
class Context : public IContext {
T *obj;
public:
Context(T *obj) : obj(obj) {}
chan<structZ> done() { return obj->done(); }
error err() { return obj->err(); }
};
#endif
// ---- misc ----
#include <unordered_map>
...
...
@@ -205,6 +259,15 @@ tuple<uint64_t, error> parseHex64(const string& s);
tuple
<
int64_t
,
error
>
parseInt
(
const
string
&
s
);
tuple
<
uint64_t
,
error
>
parseUint
(
const
string
&
s
);
}
// xstrconv
}
// xstrconv::
// zodb::
namespace
zodb
{
typedef
uint64_t
Tid
;
typedef
uint64_t
Oid
;
}
// zodb::
#endif
wcfs/internal/wcfs_virtmem.cpp
View file @
d34c4610
This diff is collapsed.
Click to expand it.
wcfs/internal/wcfs_watchlink.cpp
0 → 100644
View file @
d34c4610
This diff is collapsed.
Click to expand it.
wcfs/internal/wcfs_watchlink.h
0 → 100644
View file @
d34c4610
// Copyright (C) 2018-2019 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// wcfs_watchlink provides WatchLink class that implements message exchange
// over /head/watch.
#ifndef _NXD_WCFS_WATCHLINK_H_
#define _NXD_WCFS_WATCHLINK_H_
#include "wcfs_misc.h"
struct
WCFS
;
struct
PinReq
;
// StreamID stands for ID of a stream multiplexed over WatchLink.
typedef
uint64_t
StreamID
;
// rxPkt internally represents data of one message received over WatchLink.
struct
rxPkt
{
// stream over which the data was received
StreamID
stream
;
// raw data received/to-be-sent.
// XXX not e.g. string as chan<T> currently does not support types with
// non-trivial copy. Note: we anyway need to limit rx line length to
// avoid DoS, but just for DoS the limit would be higher.
uint16_t
datalen
;
char
data
[
128
-
sizeof
(
StreamID
)
-
sizeof
(
uint16_t
)];
error
from_string
(
const
string
&
rx
);
string
to_string
()
const
;
};
static_assert
(
sizeof
(
rxPkt
)
==
128
);
// WatchLink represents /head/watch link opened on wcfs.
//
// It is created by WCFS::_openwatch().
//
// .sendReq()/.recvReq() provides raw IO in terms of wcfs invalidation protocol messages.
// .close() closes the link.
//
// It is safe to use WatchLink from multiple threads simultaneously.
class
WatchLink
{
WCFS
*
_wc
;
os
::
File
_f
;
// head/watch file handle
string
_rxbuf
;
// buffer for read data from _f
chan
<
structZ
>
_rx_eof
;
// becomes ready when wcfs closes its tx side
// inv.protocol message IO
chan
<
rxPkt
>
_acceptq
;
// server originated messages go here
sync
::
Mutex
_rxmu
;
bool
_rxdown
;
dict
<
StreamID
,
chan
<
rxPkt
>>
_rxtab
;
// {} stream -> rxq server replies go via here
set
<
StreamID
>
_accepted
;
// streams we accepted but did not replied yet
StreamID
_req_next
;
// stream ID for next client-originated request XXX -> atomic
sync
::
Mutex
_txmu
;
// serializes writes
sync
::
Once
_txclose1
;
#if 0
func() _serveCancel
sync.WorkGroup *_serveWG
#endif
public:
//friend tuple<WatchLink*, error> WCFS::_openwatch();
error
close
();
error
recvReq
(
IContext
*
ctx
,
PinReq
*
rx_into
);
tuple
<
string
,
error
>
sendReq
(
IContext
*
ctx
,
const
string
&
req
);
private:
void
_closeTX
();
error
_serveRX
(
IContext
*
ctx
);
tuple
<
string
,
error
>
_readline
();
error
_send
(
StreamID
stream
,
const
string
&
msg
);
error
_write
(
const
string
&
pkt
);
tuple
<
chan
<
rxPkt
>
,
error
>
_sendReq
(
IContext
*
ctx
,
const
string
&
req
);
};
// PinReq represents 1 server-initiated wcfs pin request received over /head/watch link.
struct
PinReq
{
StreamID
stream
;
// request was received with this stream ID
zodb
::
Oid
foid
;
// request is about this file
int64_t
blk
;
// ----//---- about this block
zodb
::
Tid
at
;
// pin to this at; TidHead means unpin to head
};
#endif
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