Commit 6bde31f8 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e95955e3
......@@ -24,6 +24,13 @@
#include <golang/fmt.h>
#include <string.h>
// XXX temp, place, ok=?
const char *v(error err) {
if (err != nil)
return err->Error().c_str(); // XXX Error() gives temp. obj
return "nil";
}
_WatchLink::_WatchLink() {}
_WatchLink::~_WatchLink() {}
void _WatchLink::decref() {
......@@ -93,7 +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));
error err2 = wlink._f->close();
printf("close -> err2=%s\n", (err != nil ? err->Error().c_str() : "nil"));
if (err == nil)
err = err2;
......@@ -124,18 +135,21 @@ error _WatchLink::_serveRX(context::Context ctx) { // XXX error -> where ?
// NOTE: .close() makes sure .f.read*() will wake up
printf("serveRX -> readline ...\n");
tie(l, err) = wlink._readline(); // XXX +maxlen
printf(" readline -> woken up; l='%s' ; err='%s'\n", l.c_str(),
(err != nil ? err->Error().c_str() : "nil"));
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();
}
if (err != nil)
if (err != nil) {
// XXX place=ok?
if (err == io::EOF_)
err = nil;
return err;
}
printf("C: watch : rx: %s", l.c_str());
err = pkt.from_string(l);
printf("line -> pkt: err='%s'\n", (err != nil ? err->Error().c_str() : "nil"));
printf("line -> pkt: err='%s'\n", v(err));
if (err != nil)
return err;
......@@ -366,7 +380,7 @@ tuple<string, error> _WatchLink::_readline() {
error err;
printf("\t_readline -> read ...\n");
tie(n, err) = wlink._f->read(buf, sizeof(buf));
printf("\t_readline -> read: n=%d err='%s'\n", n, (err != nil ? err->Error().c_str() : "nil"));
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