Skip to content
Snippets Groups Projects
Commit 28ae652a authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Try to unlock recv mutex earlier

parent 2c4eff81
No related branches found
No related tags found
1 merge request!37Resolves #83 net performance, partially
Pipeline #11524 passed
...@@ -417,15 +417,6 @@ void Peer::data() { ...@@ -417,15 +417,6 @@ void Peer::data() {
bool Peer::_data() { bool Peer::_data() {
std::unique_lock<std::recursive_mutex> lk(recv_mtx_); std::unique_lock<std::recursive_mutex> lk(recv_mtx_);
/*recv_buf_.reserve_buffer(kMaxMessage);
int rc = ftl::net::internal::recv(sock_, recv_buf_.buffer(), kMaxMessage, 0);
if (rc <= 0) {
return false;
}
recv_buf_.buffer_consumed(rc);*/
if (scheme_ == ftl::URI::SCHEME_WS && !ws_read_header_) { if (scheme_ == ftl::URI::SCHEME_WS && !ws_read_header_) {
wsheader_type ws; wsheader_type ws;
if (ws_parse(recv_buf_, ws) < 0) { if (ws_parse(recv_buf_, ws) < 0) {
...@@ -436,6 +427,8 @@ bool Peer::_data() { ...@@ -436,6 +427,8 @@ bool Peer::_data() {
msgpack::object_handle msg; msgpack::object_handle msg;
while (recv_buf_.next(msg)) { while (recv_buf_.next(msg)) {
// CHECK Safe to unlock here?
lk.unlock();
ws_read_header_ = false; ws_read_header_ = false;
msgpack::object obj = msg.get(); msgpack::object obj = msg.get();
if (status_ != kConnected) { if (status_ != kConnected) {
...@@ -457,6 +450,9 @@ bool Peer::_data() { ...@@ -457,6 +450,9 @@ bool Peer::_data() {
} }
disp_->dispatch(*this, obj); disp_->dispatch(*this, obj);
// Relock before next loop of while
lk.lock();
if (scheme_ == ftl::URI::SCHEME_WS && recv_buf_.nonparsed_size() > 0) { if (scheme_ == ftl::URI::SCHEME_WS && recv_buf_.nonparsed_size() > 0) {
wsheader_type ws; wsheader_type ws;
if (ws_parse(recv_buf_, ws) < 0) { if (ws_parse(recv_buf_, ws) < 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment