aboutsummaryrefslogtreecommitdiff
path: root/zenhttp/httpasio.cpp
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2022-02-03 13:49:27 +0100
committerPer Larsson <[email protected]>2022-02-03 13:49:27 +0100
commit011227e58ec2928c392bd153f7350919c31eaed7 (patch)
tree5a23ed9e346efb2e26a598e1290e8a1d1849964f /zenhttp/httpasio.cpp
parentAdded encryption key/IV option in LUA. (diff)
parentFixed signed/unsigned comparison compile error (diff)
downloadzen-011227e58ec2928c392bd153f7350919c31eaed7.tar.xz
zen-011227e58ec2928c392bd153f7350919c31eaed7.zip
Merge branch 'main' into auth
Diffstat (limited to 'zenhttp/httpasio.cpp')
-rw-r--r--zenhttp/httpasio.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/zenhttp/httpasio.cpp b/zenhttp/httpasio.cpp
index f2d48200e..55ce867a4 100644
--- a/zenhttp/httpasio.cpp
+++ b/zenhttp/httpasio.cpp
@@ -12,6 +12,7 @@
ZEN_THIRD_PARTY_INCLUDES_START
#if ZEN_PLATFORM_WINDOWS
# include <conio.h>
+# include <mstcpip.h>
#endif
#include <http_parser.h>
#include <asio.hpp>
@@ -934,12 +935,26 @@ struct HttpAcceptor
m_Acceptor.set_option(asio::ip::v6_only(false));
m_Acceptor.set_option(asio::socket_base::reuse_address(true));
m_Acceptor.set_option(asio::ip::tcp::no_delay(true));
+ m_Acceptor.set_option(asio::socket_base::receive_buffer_size(128 * 1024));
+ m_Acceptor.set_option(asio::socket_base::send_buffer_size(256 * 1024));
+
asio::error_code BindErrorCode;
m_Acceptor.bind(asio::ip::tcp::endpoint(asio::ip::address_v6::any(), Port), BindErrorCode);
if (BindErrorCode == asio::error::access_denied)
{
m_Acceptor.bind(asio::ip::tcp::endpoint(asio::ip::address_v6::any(), 0));
}
+
+#if ZEN_PLATFORM_WINDOWS
+ // On Windows, loopback connections can take advantage of a faster code path optionally with this flag.
+ // This must be used by both the client and server side, and is only effective in the absence of
+ // Windows Filtering Platform (WFP) callouts which can be installed by security software.
+ // https://docs.microsoft.com/en-us/windows/win32/winsock/sio-loopback-fast-path
+ SOCKET NativeSocket = m_Acceptor.native_handle();
+ int LoopbackOptionValue = 1;
+ DWORD OptionNumberOfBytesReturned = 0;
+ WSAIoctl(NativeSocket, SIO_LOOPBACK_FAST_PATH, &LoopbackOptionValue, sizeof(LoopbackOptionValue), NULL, 0, &OptionNumberOfBytesReturned, 0, 0);
+#endif
m_Acceptor.listen();
}
@@ -969,6 +984,8 @@ struct HttpAcceptor
// reference to the callbacks.
Socket->set_option(asio::ip::tcp::no_delay(true));
+ Socket->set_option(asio::socket_base::receive_buffer_size(128*1024));
+ Socket->set_option(asio::socket_base::send_buffer_size(256*1024));
auto Conn = std::make_shared<HttpServerConnection>(m_Server, std::move(Socket));
Conn->HandleNewRequest();