diff --git a/src/networks/client.cpp b/src/networks/client.cpp index e082a2c..03d39e3 100644 --- a/src/networks/client.cpp +++ b/src/networks/client.cpp @@ -1110,7 +1110,7 @@ void client_mode::process_disconnect(uint32_t conv) std::shared_ptr kcp_mappings_ptr = kcp_channel_iter->second; std::shared_ptr kcp_ptr = kcp_mappings_ptr->egress_kcp; - if (std::scoped_lock locker_expiring_kcp{ mutex_expiring_kcp }; expiring_kcp.find(kcp_ptr) == expiring_kcp.end()) + if (std::scoped_lock locker_expiring_kcp{ mutex_expiring_kcp }; expiring_kcp.find(kcp_mappings_ptr) == expiring_kcp.end()) expiring_kcp.insert({ kcp_mappings_ptr, packet::right_now() }); if (std::scoped_lock locker_kcp_keepalive{mutex_kcp_keepalive}; kcp_keepalive.find(kcp_ptr) != kcp_keepalive.end()) diff --git a/src/networks/client.hpp b/src/networks/client.hpp index 34ecdf6..ca25c27 100644 --- a/src/networks/client.hpp +++ b/src/networks/client.hpp @@ -15,7 +15,7 @@ class client_mode std::unique_ptr udp_access_point; std::shared_mutex mutex_handshakes; - std::map> handshakes; + std::unordered_map> handshakes; std::shared_mutex mutex_udp_local_session_map_to_kcp; std::map> udp_local_session_map_to_kcp; @@ -23,17 +23,17 @@ class client_mode std::mutex mutex_udp_address_map_to_handshake; std::map> udp_address_map_to_handshake; std::mutex mutex_udp_seesion_caches; - std::map, std::vector>, std::owner_less<>> udp_seesion_caches; + std::unordered_map, std::vector>> udp_seesion_caches; std::shared_mutex mutex_kcp_channels; - std::map> kcp_channels; + std::unordered_map> kcp_channels; std::mutex mutex_expiring_kcp; - std::map, int64_t, std::owner_less<>> expiring_kcp; + std::unordered_map, int64_t> expiring_kcp; std::mutex mutex_expiring_handshakes; - std::map, int64_t, std::owner_less<>> expiring_handshakes; + std::unordered_map, int64_t> expiring_handshakes; std::mutex mutex_expiring_forwarders; - std::map, int64_t, std::owner_less<>> expiring_forwarders; + std::unordered_map, int64_t> expiring_forwarders; std::shared_mutex mutex_target_address; std::unique_ptr target_address; @@ -42,7 +42,7 @@ class client_mode std::map, std::atomic, std::owner_less<>> kcp_keepalive; std::shared_mutex mutex_id_map_to_mux_records; - std::map> id_map_to_mux_records; // (KCP conv << 32) + connection uid + std::unordered_map> id_map_to_mux_records; // (KCP conv << 32) + connection uid std::shared_mutex mutex_udp_map_to_mux_records; std::map> udp_map_to_mux_records; diff --git a/src/networks/connections.hpp b/src/networks/connections.hpp index 53f754c..be54281 100644 --- a/src/networks/connections.hpp +++ b/src/networks/connections.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/src/networks/relay.hpp b/src/networks/relay.hpp index d2dfe0e..ec04f70 100644 --- a/src/networks/relay.hpp +++ b/src/networks/relay.hpp @@ -20,21 +20,21 @@ class relay_mode std::array external_ipv6_address; const std::array zero_value_array; - std::map> udp_servers; + std::unordered_map> udp_servers; std::shared_mutex mutex_id_map_to_both_sides; - std::map> id_map_to_both_sides; + std::unordered_map> id_map_to_both_sides; std::shared_mutex mutex_handshake_ingress_map_to_channels; std::map> handshake_ingress_map_to_channels; std::mutex mutex_expiring_kcp; - std::map, int64_t, std::owner_less<>> expiring_kcp; + std::unordered_map, int64_t> expiring_kcp; std::mutex mutex_expiring_handshakes; std::map, int64_t, std::owner_less<>> expiring_handshakes; std::mutex mutex_expiring_forwarders; - std::map, int64_t, std::owner_less<>> expiring_forwarders; + std::unordered_map, int64_t> expiring_forwarders; std::shared_mutex mutex_kcp_keepalive_ingress; std::map, std::atomic, std::owner_less<>> kcp_keepalive_ingress; diff --git a/src/networks/server.hpp b/src/networks/server.hpp index d1c8428..438f8a4 100644 --- a/src/networks/server.hpp +++ b/src/networks/server.hpp @@ -20,15 +20,15 @@ class server_mode std::array external_ipv6_address; const std::array zero_value_array; - std::map> udp_servers; + std::unordered_map> udp_servers; std::shared_mutex mutex_handshake_channels; std::map> handshake_channels; std::shared_mutex mutex_kcp_channels; - std::map> kcp_channels; + std::unordered_map> kcp_channels; std::mutex mutex_expiring_kcp; - std::map, int64_t, std::owner_less<>> expiring_kcp; + std::unordered_map, int64_t> expiring_kcp; std::mutex mutex_expiring_handshakes; std::map, int64_t, std::owner_less<>> expiring_handshakes; @@ -36,10 +36,10 @@ class server_mode std::map, std::atomic, std::owner_less<>> kcp_keepalive; std::shared_mutex mutex_id_map_to_mux_records; - std::map> id_map_to_mux_records; // (KCP conv << 32) + connection uid + std::unordered_map> id_map_to_mux_records; // (KCP conv << 32) + connection uid std::shared_mutex mutex_expiring_mux_records; - std::map> expiring_mux_records; // (KCP conv << 32) + connection uid + std::unordered_map> expiring_mux_records; // (KCP conv << 32) + connection uid std::shared_mutex mutex_mux_tcp_cache; std::map, std::deque, std::owner_less<>> mux_tcp_cache;