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

Handle handshake message immediately

parent d9fc99af
No related branches found
No related tags found
1 merge request!59Resolves #122 with handshake fix
Pipeline #11953 passed
......@@ -465,22 +465,27 @@ bool Peer::_data() {
_badClose(false);
LOG(ERROR) << "Missing handshake - got '" << get<1>(hs) << "'";
return false;
} else {
// Must handle immediately with no other thread able
// to read next message before completion.
// The handshake handler must not block.
disp_->dispatch(*this, obj);
}
} catch(...) {
_badClose(false);
LOG(ERROR) << "Bad first message format";
return false;
}
} else {
// 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;
}
// 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;
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