Commit 0e0c6522 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e23f0fc1
...@@ -70,6 +70,8 @@ cdef extern from "wcfs_watchlink.h" nogil: ...@@ -70,6 +70,8 @@ cdef extern from "wcfs_watchlink.h" nogil:
Tid at Tid at
string msg string msg
error _twlinkwrite(WatchLink wlink, const string& pkt)
cdef extern from "wcfs.h" nogil: cdef extern from "wcfs.h" nogil:
cppclass WCFS: cppclass WCFS:
...@@ -175,6 +177,13 @@ cdef class PyPinReq: ...@@ -175,6 +177,13 @@ cdef class PyPinReq:
return pypin.pinreq.msg return pypin.pinreq.msg
def _tpywlinkwrite(PyWatchLink pywlink, bytes pypkt):
cdef string pkt = pypkt
with nogil:
err = _twlinkwrite_pyexc(pywlink.wlink, pkt)
if err != nil:
raise RuntimeError(err.Error()) # XXX exc class?
# ---- misc ---- # ---- misc ----
from golang cimport topyexc from golang cimport topyexc
...@@ -195,3 +204,6 @@ cdef nogil: ...@@ -195,3 +204,6 @@ cdef nogil:
pair[string, error] wlink_sendReq_pyexc(WatchLink wlink, context.Context ctx, const string &req) except +topyexc: pair[string, error] wlink_sendReq_pyexc(WatchLink wlink, context.Context ctx, const string &req) except +topyexc:
return wlink.sendReq(ctx, req) return wlink.sendReq(ctx, req)
error _twlinkwrite_pyexc(WatchLink wlink, const string& pkt) except +topyexc:
return _twlinkwrite(wlink, pkt)
...@@ -224,6 +224,9 @@ error _WatchLink::_send(StreamID stream, const string &msg) { ...@@ -224,6 +224,9 @@ error _WatchLink::_send(StreamID stream, const string &msg) {
return wlink->_write(pkt); return wlink->_write(pkt);
} }
error _twlinkwrite(WatchLink wlink, const string &pkt) {
return wlink->_write(pkt);
}
error _WatchLink::_write(const string &pkt) { error _WatchLink::_write(const string &pkt) {
_WatchLink *wlink = this; _WatchLink *wlink = this;
......
...@@ -113,6 +113,8 @@ private: ...@@ -113,6 +113,8 @@ private:
error _send(StreamID stream, const string &msg); error _send(StreamID stream, const string &msg);
error _write(const string &pkt); error _write(const string &pkt);
tuple<chan<rxPkt>, error> _sendReq(context::Context ctx, const string &req); tuple<chan<rxPkt>, error> _sendReq(context::Context ctx, const string &req);
friend error _twlinkwrite(WatchLink wlink, const string &pkt);
}; };
// PinReq represents 1 server-initiated wcfs pin request received over /head/watch link. // PinReq represents 1 server-initiated wcfs pin request received over /head/watch link.
...@@ -126,4 +128,7 @@ struct PinReq { ...@@ -126,4 +128,7 @@ struct PinReq {
}; };
// for testing
error _twlinkwrite(WatchLink wlink, const string &pkt);
#endif #endif
...@@ -52,6 +52,7 @@ import pytest; xfail = pytest.mark.xfail ...@@ -52,6 +52,7 @@ import pytest; xfail = pytest.mark.xfail
from pytest import raises, fail from pytest import raises, fail
from six import reraise from six import reraise
from .internal import io, mm from .internal import io, mm
from .internal._wcfs import _tpywlinkwrite as _twlinkwrite
from .internal.wcfs_test import _tDB, read_nogil, install_sigbus_trap, fadvise_dontneed from .internal.wcfs_test import _tDB, read_nogil, install_sigbus_trap, fadvise_dontneed
# XXX `py.test -v` -> WENDELIN_CORE_WCFS_OPTIONS += -v=1? # XXX `py.test -v` -> WENDELIN_CORE_WCFS_OPTIONS += -v=1?
...@@ -1240,7 +1241,7 @@ def test_wcfs_watch_robust(): ...@@ -1240,7 +1241,7 @@ def test_wcfs_watch_robust():
# invalid request not following frame structure -> fatal + wcfs must close watch link # invalid request not following frame structure -> fatal + wcfs must close watch link
assert wl.fatalv == [] assert wl.fatalv == []
wl._write(b'zzz hello\n') _twlinkwrite(wl, b'zzz hello\n')
_, _rx = select( _, _rx = select(
timeout().done().recv, timeout().done().recv,
wl.rx_eof.recv, wl.rx_eof.recv,
......
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