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

.

parent e95955e3
...@@ -24,6 +24,13 @@ ...@@ -24,6 +24,13 @@
#include <golang/fmt.h> #include <golang/fmt.h>
#include <string.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() {}
_WatchLink::~_WatchLink() {} _WatchLink::~_WatchLink() {}
void _WatchLink::decref() { void _WatchLink::decref() {
...@@ -93,7 +100,11 @@ error _WatchLink::close() { ...@@ -93,7 +100,11 @@ error _WatchLink::close() {
if (err == context::canceled) if (err == context::canceled)
err = nil; 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(); error err2 = wlink._f->close();
printf("close -> err2=%s\n", (err != nil ? err->Error().c_str() : "nil"));
if (err == nil) if (err == nil)
err = err2; err = err2;
...@@ -124,18 +135,21 @@ error _WatchLink::_serveRX(context::Context ctx) { // XXX error -> where ? ...@@ -124,18 +135,21 @@ error _WatchLink::_serveRX(context::Context ctx) { // XXX error -> where ?
// NOTE: .close() makes sure .f.read*() will wake up // NOTE: .close() makes sure .f.read*() will wake up
printf("serveRX -> readline ...\n"); printf("serveRX -> readline ...\n");
tie(l, err) = wlink._readline(); // XXX +maxlen tie(l, err) = wlink._readline(); // XXX +maxlen
printf(" readline -> woken up; l='%s' ; err='%s'\n", l.c_str(), printf(" readline -> woken up; l='%s' ; err='%s'\n", l.c_str(), v(err));
(err != nil ? err->Error().c_str() : "nil"));
if (err == io::EOF_) { // peer closed its tx if (err == io::EOF_) { // peer closed its tx
// XXX what happens on other errors? // XXX what happens on other errors?
wlink._rx_eof.close(); wlink._rx_eof.close();
} }
if (err != nil) if (err != nil) {
// XXX place=ok?
if (err == io::EOF_)
err = nil;
return err; return err;
}
printf("C: watch : rx: %s", l.c_str()); printf("C: watch : rx: %s", l.c_str());
err = pkt.from_string(l); 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) if (err != nil)
return err; return err;
...@@ -366,7 +380,7 @@ tuple<string, error> _WatchLink::_readline() { ...@@ -366,7 +380,7 @@ tuple<string, error> _WatchLink::_readline() {
error err; error err;
printf("\t_readline -> read ...\n"); printf("\t_readline -> read ...\n");
tie(n, err) = wlink._f->read(buf, sizeof(buf)); 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) { if (n > 0) {
// XXX limit line length to avoid DoS // XXX limit line length to avoid DoS
wlink._rxbuf += string(buf, n); 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