From b0eeda9eb4e9cce92845056b9a6879c0326b70b0 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Fri, 14 Jun 2019 15:44:48 +0300 Subject: [PATCH] Code tidy and notes --- components/net/cpp/src/peer.cpp | 9 ++++++++- components/net/cpp/src/universe.cpp | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/components/net/cpp/src/peer.cpp b/components/net/cpp/src/peer.cpp index 07deffe38..c32d62783 100644 --- a/components/net/cpp/src/peer.cpp +++ b/components/net/cpp/src/peer.cpp @@ -401,7 +401,12 @@ void Peer::data() { return; } - int rc = ftl::net::internal::recv(sock_, recv_buf_.buffer(), recv_buf_.buffer_capacity(), 0); + int cap = recv_buf_.buffer_capacity(); + int rc = ftl::net::internal::recv(sock_, recv_buf_.buffer(), cap, 0); + + if (rc >= cap) { + LOG(WARNING) << "More than buffers worth of data received"; + } if (rc <= 0) { return; @@ -410,6 +415,8 @@ void Peer::data() { recv_buf_.buffer_consumed(rc); lk.unlock(); + LOG(INFO) << "Received " << rc << " bytes"; + pool.push([](int id, Peer *p) { p->_data(); //p->is_waiting_ = true; diff --git a/components/net/cpp/src/universe.cpp b/components/net/cpp/src/universe.cpp index af510a710..1a7e808a1 100644 --- a/components/net/cpp/src/universe.cpp +++ b/components/net/cpp/src/universe.cpp @@ -141,9 +141,9 @@ int Universe::_setDescriptors() { n = s->_socket(); } - if (s->isWaiting()) { + //if (s->isWaiting()) { FD_SET(s->_socket(), &sfdread_); - } + //} FD_SET(s->_socket(), &sfderror_); } } @@ -323,6 +323,7 @@ void Universe::_run() { continue; } + // CHECK Could this mutex be the problem!? unique_lock<shared_mutex> lk(net_mutex_); //If connection request is waiting -- GitLab