Commit 1301bbc7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 5c02054e
...@@ -41,6 +41,7 @@ using namespace golang; ...@@ -41,6 +41,7 @@ using namespace golang;
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <stdint.h> #include <stdint.h>
#include <inttypes.h>
#include "wcfs_misc.h" #include "wcfs_misc.h"
...@@ -470,12 +471,13 @@ error WatchLink::_serveRX(IContext *ctx) { // XXX error -> where ? ...@@ -470,12 +471,13 @@ error WatchLink::_serveRX(IContext *ctx) { // XXX error -> where ?
string l; string l;
error err; error err;
rxPkt pkt;
while (1) { while (1) {
// NOTE: .close() makes sure .f.read*() will wake up // NOTE: .close() makes sure .f.read*() will wake up
tie(l, err) = wlink._readline(); tie(l, err) = wlink._readline();
if (err == io::EOF_) { // peer closed its tx if (err == io::EOF_) { // peer closed its tx
// XXX what happens with other errors? // XXX what happens on other errors?
wlink._rx_eof.close(); wlink._rx_eof.close();
} }
if (err != nil) if (err != nil)
...@@ -483,6 +485,24 @@ error WatchLink::_serveRX(IContext *ctx) { // XXX error -> where ? ...@@ -483,6 +485,24 @@ error WatchLink::_serveRX(IContext *ctx) { // XXX error -> where ?
printf("C: watch : rx: %s", l.c_str()); printf("C: watch : rx: %s", l.c_str());
// <stream> ... \n // <stream> ... \n
sp = l.find(' ');
if (sp == string::npos) {
// XXX invalid pkt: no sp
return fmt.errorf("invalid pkt: no SP");
}
sid = string(l, 0, sp);
smsg = string(l, sp+1);
sscanf(sid.c_str(), "%" SCNu64, &pkt.streamID);
snprintf(...., "%" PRIu64, pkt.streamID);
if (string(...) != sid)
return fmt.errorf("invalid pkt: invalid stream ID");
// XXX len(data) > pkt.data?
// XXX copy data -> pkt.data
stream, msg = l.split(' ', 1) stream, msg = l.split(' ', 1)
stream = int(stream) stream = int(stream)
msg = msg.rstrip('\n') msg = msg.rstrip('\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