diff --git a/components/net/cpp/include/ftl/net/peer.hpp b/components/net/cpp/include/ftl/net/peer.hpp index 605c0fb0d09edea08685ffbe21c78471f9f05f21..16393a55c9cd055971531903cf62f58a84b87a85 100644 --- a/components/net/cpp/include/ftl/net/peer.hpp +++ b/components/net/cpp/include/ftl/net/peer.hpp @@ -320,8 +320,6 @@ int Peer::asyncCall( ARGS... args) { auto args_obj = std::make_tuple(args...); auto rpcid = 0; - - LOG(INFO) << "RPC " << name << "() -> " << uri_; { // Could this be the problem???? @@ -331,6 +329,8 @@ int Peer::asyncCall( callbacks_[rpcid] = std::make_unique<caller<T>>(cb); } + LOG(INFO) << "RPC " << name << "(" << rpcid << ") -> " << uri_; + auto call_obj = std::make_tuple(0,rpcid,name,args_obj); UNIQUE_LOCK(send_mtx_,lk); diff --git a/components/net/cpp/src/peer.cpp b/components/net/cpp/src/peer.cpp index 04beff81f5f5891bc293f31100918e316f3df015..f3f875ae8e648c176159417adf9711318ae3cb7d 100644 --- a/components/net/cpp/src/peer.cpp +++ b/components/net/cpp/src/peer.cpp @@ -409,9 +409,11 @@ void Peer::data() { } if (cap < (kMaxMessage / 10)) LOG(WARNING) << "NO BUFFER"; - if (rc <= 0) { - //LOG(WARNING) << "Weird rc: " << rc; - //close(); + if (rc == 0) { + close(); + return; + } else if (rc < 0) { + socketError(); return; } @@ -427,7 +429,7 @@ void Peer::data() { } lk.unlock(); - LOG(INFO) << "Received " << rc << " bytes"; + //LOG(INFO) << "Received " << rc << " bytes"; } bool Peer::_data() { @@ -443,8 +445,6 @@ bool Peer::_data() { msgpack::object_handle msg; while (recv_buf_.next(msg)) { - // CHECK Safe to unlock here? - lk.unlock(); ws_read_header_ = false; msgpack::object obj = msg.get(); if (status_ != kConnected) { @@ -464,10 +464,14 @@ bool Peer::_data() { return false; } } - disp_->dispatch(*this, obj); + // CHECK Safe to unlock here? + is_waiting_ = true; + lk.unlock(); + disp_->dispatch(*this, obj); // Relock before next loop of while lk.lock(); + is_waiting_ = false; if (scheme_ == ftl::URI::SCHEME_WS && recv_buf_.nonparsed_size() > 0) { wsheader_type ws; diff --git a/components/rgbd-sources/src/net.cpp b/components/rgbd-sources/src/net.cpp index c23ec9376250b379f9314e8e3a01950fdf7a281c..ef3fdd5d270288cd6c73422d0651cb40bced7b82 100644 --- a/components/rgbd-sources/src/net.cpp +++ b/components/rgbd-sources/src/net.cpp @@ -64,8 +64,6 @@ NetSource::~NetSource() { void NetSource::_recv(const vector<unsigned char> &jpg, const vector<unsigned char> &d) { cv::Mat tmp_rgb, tmp_depth; - DLOG(INFO) << "Received frame"; - // Decode in temporary buffers to prevent long locks cv::imdecode(jpg, cv::IMREAD_COLOR, &tmp_rgb); cv::imdecode(d, cv::IMREAD_UNCHANGED, &tmp_depth); diff --git a/components/rgbd-sources/src/streamer.cpp b/components/rgbd-sources/src/streamer.cpp index 651434ee02a2f70488fc05f6e27ca023abb8cc87..9b90cd4b8e7235aee0b2211dcda343b1b1d35e2e 100644 --- a/components/rgbd-sources/src/streamer.cpp +++ b/components/rgbd-sources/src/streamer.cpp @@ -170,7 +170,7 @@ void Streamer::poll() { if (elapsed.count() >= wait) { LOG(WARNING) << "Frame rate below optimal @ " << (1.0f / elapsed.count()); } else { - LOG(INFO) << "Frame rate @ " << (1.0f / elapsed.count()); + //LOG(INFO) << "Frame rate @ " << (1.0f / elapsed.count()); // Otherwise, wait until next frame should start. // CHECK(Nick) Is this accurate enough? Almost certainly not // TODO(Nick) Synchronise by time corrections and use of fixed time points