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

Commit

Permalink
KEP-1298 Enable TCP_QUICKACK
Browse files Browse the repository at this point in the history
  • Loading branch information
ebruck committed Mar 27, 2019
1 parent b8797a3 commit 0d5029b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 8 additions & 1 deletion node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <node/session.hpp>
#include <utils/make_endpoint.hpp>
#include <pbft/pbft.hpp>
#include <netinet/tcp.h>

using namespace bzn;

Expand Down Expand Up @@ -94,7 +95,13 @@ node::do_accept()
self->acceptor_socket->get_tcp_socket().set_option(boost::asio::ip::tcp::no_delay(true), option_ec);
if (option_ec)
{
LOG(warning) << "failed to set socket option: " << option_ec.message();
LOG(warning) << "failed to set socket option TCP_NODELAY: " << option_ec.message();
}

int flags = 1;
if (setsockopt(self->acceptor_socket->get_tcp_socket().native_handle(), SOL_TCP, TCP_QUICKACK, &flags, sizeof(flags)))
{
LOG(warning) << "failed to set socket option TCP_QUICKACK: " << errno;
}

std::shared_ptr<bzn::beast::websocket_stream_base> ws = self->websocket->make_unique_websocket_stream(
Expand Down
10 changes: 8 additions & 2 deletions node/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <node/node.hpp>
#include <sstream>
#include <boost/beast/websocket/error.hpp>

#include <netinet/tcp.h>

using namespace bzn;

Expand Down Expand Up @@ -95,7 +95,13 @@ session::open(std::shared_ptr<bzn::beast::websocket_base> ws_factory)
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();
LOG(warning) << "failed to set socket option TCP_NODELAY: " << option_ec.message();
}

int flags = 1;
if (setsockopt(socket->get_tcp_socket().native_handle(), SOL_TCP, TCP_QUICKACK, &flags, sizeof(flags)))
{
LOG(warning) << "failed to set socket option TCP_QUICKACK: " << errno;
}

self->websocket = ws_factory->make_unique_websocket_stream(socket->get_tcp_socket());
Expand Down

0 comments on commit 0d5029b

Please sign in to comment.