Commit df371d3f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 92002789
......@@ -167,7 +167,7 @@ error map_into(void *addr, size_t size, int prot, int flags, const os::File f, o
namespace strings {
bool has_prefix(const string &s, const string &prefix) {
return s.compare(0, prefix.size(), prefix);
return s.compare(0, prefix.size(), prefix) == 0; // XXX -> pygolang + tests
}
bool has_prefix(const string &s, char prefix) {
......
......@@ -117,6 +117,7 @@ error _WatchLink::_serveRX(context::Context ctx) { // XXX error -> where ?
// when finishing - wakeup everyone waiting for rx
defer([&]() {
printf("serveRX: close all chans\n");
wlink._acceptq.close();
wlink._rxmu.lock();
wlink._rxdown = true; // don't allow new rxtab registers
......@@ -135,7 +136,7 @@ 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(), 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();
......@@ -317,19 +318,25 @@ error _WatchLink::recvReq(context::Context ctx, PinReq *prx) {
if (!ok)
return io::EOF_;
pkt.to_string();
//pkt.to_string();
return _parsePinReq(prx, &pkt);
}
// _parsePinReq parses message into PinReq according to wcfs invalidation protocol.
static error _parsePinReq(PinReq *pin, const rxPkt *pkt) {
// XXX err ctx "bad pin"
printf("parse pinreq: stream=%lu msg='%s'\n", pkt->stream, &pkt->data[0]);
pin->stream = pkt->stream;
auto msg = pkt->to_string();
string msg = pkt->to_string();
printf("'%s'\n", msg.c_str());
printf("has_prefix: %i\n", strings::has_prefix(msg, "pin "));
// pin <foid>) #<blk> @<at>
if (!strings::has_prefix(msg, "pin "))
if (!strings::has_prefix(msg, "pin ")) {
printf("\n\n\nnot a pin request: '%s'\n", msg.c_str()); // XXX temp
abort();
return fmt::errorf("not a pin request: '%s'", msg.c_str()); // XXX msg -> errctx ?
}
auto argv = strings::split(msg.substr(4), ' ');
if (argv.size() != 3)
......
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