Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
KEP-1240 Enable TCP_NODELAY (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebruck committed Mar 13, 2019
1 parent d4a807f commit 2f2eabd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions node/node.cpp
Expand Up @@ -88,6 +88,14 @@ node::do_accept()
auto ep = self->acceptor_socket->remote_endpoint();
auto key = self->key_from_ep(ep);

// set tcp_nodelay option...
boost::system::error_code option_ec;
self->acceptor_socket->get_tcp_socket().set_option(boost::asio::ip::tcp::no_delay(true), option_ec);
if (option_ec)
{
LOG(error) << "failed to set socket option: " << option_ec.message();
}

std::shared_ptr<bzn::beast::websocket_stream_base> ws = self->websocket->make_unique_websocket_stream(
self->acceptor_socket->get_tcp_socket());

Expand Down
9 changes: 9 additions & 0 deletions node/session.cpp
Expand Up @@ -84,6 +84,15 @@ session::open(std::shared_ptr<bzn::beast::websocket_base> ws_factory)
// we've completed the handshake...

std::lock_guard<std::mutex> lock(self->socket_lock);

// set tcp_nodelay option
boost::system::error_code option_ec;
socket->get_tcp_socket().set_option(boost::asio::ip::tcp::no_delay(true), option_ec);
if (option_ec)
{
LOG(error) << "failed to set socket option: " << option_ec.message();
}

self->websocket = ws_factory->make_unique_websocket_stream(socket->get_tcp_socket());
self->websocket->async_handshake(self->ep.address().to_string(), "/",
[self, ws_factory](const boost::system::error_code& ec)
Expand Down

0 comments on commit 2f2eabd

Please sign in to comment.