Commit f3ff04c0 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 48270acd
...@@ -382,26 +382,35 @@ tuple<WatchLink*, error> WCFS::_openwatch() { ...@@ -382,26 +382,35 @@ tuple<WatchLink*, error> WCFS::_openwatch() {
// //
// multiple _send can be called in parallel - _send serializes writes. // multiple _send can be called in parallel - _send serializes writes.
// XXX +ctx? // XXX +ctx?
def WatchLink::_send(StreamID stream, const string &msg) { error WatchLink::_send(StreamID stream, const string &msg) {
WatchLink *wlink = this; WatchLink *wlink = this;
if (msg.find('\n') != string::npos) if (msg.find('\n') != string::npos)
panic("msg has \\n"); panic("msg has \\n");
// XXX Pkt is not needed here
#if 0
Pkt pkt; Pkt pkt;
pkt.stream = stream; pkt.stream = stream;
pkt.rawdata = // XXX copy msg XXX + "%d <stream> ...\n" ? pkt.rawdata = // XXX copy msg XXX + "%d <stream> ...\n" ?
//pkt = b"%d %s\n" % (stream, msg) return wlink->_write(&pkt)
wlink->_write(&pkt) #endif
pkt = fmt::sprintf("%ul %s\n", stream, msg.c_str());
} }
def WatchLink::_write(Pkt *pkt) { //error WatchLink::_write(const Pkt *pkt) {
error WatchLink::_write(const string &pkt) {
WatchLink *wlink = this; WatchLink *wlink = this;
wlink->_txmu.lock(); wlink->_txmu.lock();
defer([&]() { defer([&]() {
wlink->_txmu.unlock(); wlink->_txmu.unlock();
}) })
//printf('C: watch : tx: %r' % pkt) //printf('C: watch : tx: %r' % pkt)
wlink->_f.write(pkt); // XXX all data int n;
error err;
tie(n, err) = wlink->_f.write(pkt.c_str(), pkt.size());
return err;
#if 0 #if 0
wlink->_wtx.write(pkt); wlink->_wtx.write(pkt);
wlink->_wtx.flush(); wlink->_wtx.flush();
......
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