Commit 92002789 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 19303741
......@@ -100,11 +100,11 @@ error _WatchLink::close() {
if (err == context::canceled)
err = nil;
printf("close -> err =%s\n", (err != nil ? err->Error().c_str() : "nil"));
printf("close -> err =%s\n", v(err));
//printf("close -> err =%s\n", (err != nil ? err->Error().c_str() : "nil"));
//printf("close -> err =%s\n", v(err));
error err2 = wlink._f->close();
printf("close -> err2=%s\n", (err != nil ? err->Error().c_str() : "nil"));
//printf("close -> err2=%s\n", (err != nil ? err->Error().c_str() : "nil"));
if (err == nil)
err = err2;
......@@ -133,9 +133,9 @@ error _WatchLink::_serveRX(context::Context ctx) { // XXX error -> where ?
while (1) {
// NOTE: .close() makes sure .f.read*() will wake up
printf("serveRX -> readline ...\n");
//printf("serveRX -> readline ...\n");
tie(l, err) = wlink._readline(); // XXX +maxlen
printf(" readline -> woken up; l='%s' ; err='%s'\n", l.c_str(), v(err));
//printf(" readline -> woken up; l='%s' ; err='%s'\n", l.c_str(), v(err));
if (err == io::EOF_) { // peer closed its tx
// XXX what happens on other errors?
wlink._rx_eof.close();
......@@ -146,7 +146,7 @@ error _WatchLink::_serveRX(context::Context ctx) { // XXX error -> where ?
err = nil;
return err;
}
printf("C: watch : rx: %s", l.c_str());
printf("C: watch : rx: \"%s\"", l.c_str());
err = pkt.from_string(l);
printf("line -> pkt: err='%s'\n", v(err));
......@@ -239,7 +239,7 @@ pair<string, error> _WatchLink::sendReq(context::Context ctx, const string &req)
_WatchLink *wlink = this;
// XXX err ctx
printf("wlink sendReq '%s'\n", req.c_str());
//printf("wlink sendReq '%s'\n", req.c_str());
rxPkt rx;
chan<rxPkt> rxq;
......@@ -248,18 +248,18 @@ pair<string, error> _WatchLink::sendReq(context::Context ctx, const string &req)
if (err != nil)
return make_pair("", err);
printf("sendReq: wait ...\n");
//printf("sendReq: wait ...\n");
int _ = select({
ctx->done().recvs(), // 0
rxq.recvs(&rx), // 1
});
printf("sendReq: woken up #%d\n", _);
//printf("sendReq: woken up #%d\n", _);
if (_ == 0)
return make_pair("", ctx->err());
// XXX check for EOF
string reply = rx.to_string();
printf("sendReq: reply='%s'\n", reply.c_str());
//printf("sendReq: reply='%s'\n", reply.c_str());
return make_pair(reply, nil);
}
......@@ -371,16 +371,16 @@ tuple<string, error> _WatchLink::_readline() {
if (nl != string::npos) {
auto line = wlink._rxbuf.substr(0, nl+1);
wlink._rxbuf = wlink._rxbuf.substr(nl+1);
printf("\t_readline -> ret '%s'\n", line.c_str());
//printf("\t_readline -> ret '%s'\n", line.c_str());
return make_tuple(line, nil);
}
nl_searchfrom = wlink._rxbuf.length();
int n;
error err;
printf("\t_readline -> read ...\n");
//printf("\t_readline -> read ...\n");
tie(n, err) = wlink._f->read(buf, sizeof(buf));
printf("\t_readline -> read: n=%d err='%s'\n", n, v(err));
//printf("\t_readline -> read: n=%d err='%s'\n", n, v(err));
if (n > 0) {
// XXX limit line length to avoid DoS
wlink._rxbuf += string(buf, n);
......
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