File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323namespace Env {
2424
2525enum class Key {
26+ MAX_CONCURRENT_CONNECTIONS ,
2627 // provider settings
2728 PROVIDER_UPDATE_MESSAGE ,
2829 PROVIDER_DISABLE_CONFIG ,
Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ std::string_view Env::ToString(Env::Key key) {
4545 case Key::PROVIDER_IP_ENV :
4646 return " BEAMMP_PROVIDER_IP_ENV" ;
4747 break ;
48+ case Key::MAX_CONCURRENT_CONNECTIONS :
49+ return " BEAMMP_MAX_CONCURRENT_CONNECTIONS" ;
50+ break ;
4851 }
4952 return " " ;
5053}
Original file line number Diff line number Diff line change 1919#include " TNetwork.h"
2020#include " Client.h"
2121#include " Common.h"
22+ #include " Env.h"
2223#include " LuaAPI.h"
2324#include " TConnectionLimiter.h"
2425#include " THeartbeatThread.h"
4546
4647typedef boost::asio::detail::socket_option::integer<SOL_SOCKET , SO_RCVTIMEO > rcv_timeout_option;
4748
48- static constexpr uint8_t MAX_CONCURRENT_CONNECTIONS = 10 ;
4949static constexpr uint8_t MAX_GLOBAL_CONNECTIONS = 128 ;
50+ static const uint8_t MAX_CONCURRENT_CONNECTIONS = []() -> uint8_t {
51+ if (auto EnvVar = Env::Get (Env::Key::MAX_CONCURRENT_CONNECTIONS )) {
52+ try {
53+ beammp_debugf (" BEAMMP_MAX_CONCURRENT_CONNECTIONS: {}" , EnvVar.value ());
54+ if (const int value = std::stoi (std::string (EnvVar.value ())); value > 0 && value <= MAX_GLOBAL_CONNECTIONS ) {
55+ beammp_debugf (" BEAMMP_MAX_CONCURRENT_CONNECTIONS Parsed: {}" , value);
56+ return static_cast <uint8_t >(value);
57+ }
58+
59+ beammp_warn (" Env variable BEAMMP_MAX_CONCURRENT_CONNECTIONS is out of range, using default value." );
60+ } catch (const std::exception&) {
61+ beammp_warn (" Error parsing Env variable BEAMMP_MAX_CONCURRENT_CONNECTIONS, using default value." );
62+ }
63+ }
64+
65+ return 10 ;
66+ }();
5067static constexpr uint8_t READ_TIMEOUT_S = 10 ; // seconds
5168
5269std::vector<uint8_t > StringToVector (const std::string& Str) {
You can’t perform that action at this time.
0 commit comments