Commit c70438d5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 3c43bcbf
......@@ -218,37 +218,37 @@ error _WatchLink::_serveRX(context::Context ctx) {
//
// XXX +ctx?
error _WatchLink::_send(StreamID stream, const string &msg) {
_WatchLink *wlink = this;
_WatchLink& wlink = *this;
// XXX +errctx ?
if (msg.find('\n') != string::npos)
panic("msg has \\n");
string pkt = fmt::sprintf("%lu %s\n", stream, v(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) {
_WatchLink *wlink = this;
_WatchLink& wlink = *this;
// XXX +errctx ?
wlink->_txmu.lock();
wlink._txmu.lock();
defer([&]() {
wlink->_txmu.unlock();
wlink._txmu.unlock();
});
//trace('C: watch : tx: %r' % pkt)
int n;
error err;
tie(n, err) = wlink->_f->write(pkt.c_str(), pkt.size());
tie(n, err) = wlink._f->write(pkt.c_str(), pkt.size());
return err;
}
// sendReq sends client -> server request and returns server reply.
// XXX -> reply | None when EOF
pair<string, error> _WatchLink::sendReq(context::Context ctx, const string &req) {
_WatchLink *wlink = this;
_WatchLink& wlink = *this;
xerr::Contextf E("%s: sendReq", v(wlink)); // XXX + streamID
//printf("wlink sendReq '%s'\n", v(req));
......@@ -256,7 +256,7 @@ pair<string, error> _WatchLink::sendReq(context::Context ctx, const string &req)
rxPkt rx; bool ok;
chan<rxPkt> rxq;
error err;
tie(rxq, err) = wlink->_sendReq(ctx, req);
tie(rxq, err) = wlink._sendReq(ctx, req);
if (err != nil)
return make_pair("", E(err));
......
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