Removed possibly unnecessary is_tcp_fast_open_supported-function
This commit is contained in:
parent
0eb6269c70
commit
b7e5a37da4
2 changed files with 2 additions and 26 deletions
|
|
@ -401,11 +401,10 @@ namespace SimpleWeb {
|
|||
acceptor = std::unique_ptr<asio::ip::tcp::acceptor>(new asio::ip::tcp::acceptor(*io_service));
|
||||
acceptor->open(endpoint.protocol());
|
||||
acceptor->set_option(asio::socket_base::reuse_address(config.reuse_address));
|
||||
if (config.fast_open && is_tcp_fast_open_supported(connection_mode::server))
|
||||
{
|
||||
if(config.fast_open) {
|
||||
#if defined(__linux__) && defined(TCP_FASTOPEN)
|
||||
const int qlen = 5; // This seems to be the value that is used in other examples.
|
||||
error_code ec{};
|
||||
error_code ec;
|
||||
acceptor->set_option(asio::detail::socket_option::integer<IPPROTO_TCP, TCP_FASTOPEN>(qlen), ec);
|
||||
#endif // End Linux
|
||||
}
|
||||
|
|
|
|||
23
utility.hpp
23
utility.hpp
|
|
@ -8,10 +8,6 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#if defined(__linux__)
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#if __cplusplus > 201402L || _MSVC_LANG > 201402L
|
||||
#include <string_view>
|
||||
|
|
@ -30,25 +26,6 @@ namespace SimpleWeb {
|
|||
#endif
|
||||
|
||||
namespace SimpleWeb {
|
||||
enum class connection_mode { client = 1, server = 2 };
|
||||
inline bool is_tcp_fast_open_supported(const connection_mode mode)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
std::ifstream ifs("/proc/sys/net/ipv4/tcp_fastopen");
|
||||
if (!ifs) { return false; }
|
||||
std::string line;
|
||||
if (!std::getline(ifs, line)) { return false; }
|
||||
std::istringstream iss(line);
|
||||
int value = 0;
|
||||
iss >> value;
|
||||
if (!iss) { return false; } // Should never happen in theory.
|
||||
return (static_cast<int>(mode) & value) != 0;
|
||||
#else
|
||||
(void)mode;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool case_insensitive_equal(const std::string &str1, const std::string &str2) noexcept {
|
||||
return str1.size() == str2.size() &&
|
||||
std::equal(str1.begin(), str1.end(), str2.begin(), [](char a, char b) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue