From c3d5c33e40698da110ce5c15c25b98df901f8e9b Mon Sep 17 00:00:00 2001 From: liuchao412 Date: Wed, 27 Mar 2024 11:17:44 +0800 Subject: [PATCH] fix NetSvrManager lock bug. --- PSS_ASIO/Common/NetSvrManager.cpp | 8 ++++---- PSS_ASIO/Common/NetSvrManager.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/PSS_ASIO/Common/NetSvrManager.cpp b/PSS_ASIO/Common/NetSvrManager.cpp index 653fe2d..d5ba2fb 100644 --- a/PSS_ASIO/Common/NetSvrManager.cpp +++ b/PSS_ASIO/Common/NetSvrManager.cpp @@ -10,7 +10,7 @@ CNetSvrManager::~CNetSvrManager() void CNetSvrManager::start_default_service() { - std::lock_guard lock(list_mutex_); + std::lock_guard lock(list_mutex_); string stripport; //加载Tcp监听 @@ -98,7 +98,7 @@ void CNetSvrManager::close_all_service() { PSS_LOGGER_DEBUG("[CNetSvrManager::close_all_service]begin."); - std::lock_guard lock(list_mutex_); + std::lock_guard lock(list_mutex_); std::vector> tcp_listen_list; std::vector> tcp_listen_ssl_list; std::vector> udp_listen_list; @@ -160,7 +160,7 @@ void CNetSvrManager::close_all_service() void CNetSvrManager::add_accept_net_io_event(string io_ip, io_port_type io_port, EM_CONNECT_IO_TYPE em_io_net_type, shared_ptr Io_Net_server) { - std::lock_guard lock(list_mutex_); + std::lock_guard lock(list_mutex_); auto io_key = io_ip + "_" + std::to_string(io_port); if (EM_CONNECT_IO_TYPE::CONNECT_IO_TCP == em_io_net_type) { @@ -182,7 +182,7 @@ void CNetSvrManager::add_accept_net_io_event(string io_ip, io_port_type io_port, void CNetSvrManager::del_accept_net_io_event(string io_ip, io_port_type io_port, EM_CONNECT_IO_TYPE em_io_net_type) { - std::lock_guard lock(list_mutex_); + std::lock_guard lock(list_mutex_); auto io_key = io_ip + "_" + std::to_string(io_port); if (EM_CONNECT_IO_TYPE::CONNECT_IO_TCP == em_io_net_type) { diff --git a/PSS_ASIO/Common/NetSvrManager.h b/PSS_ASIO/Common/NetSvrManager.h index fa1b3d5..d4c147b 100644 --- a/PSS_ASIO/Common/NetSvrManager.h +++ b/PSS_ASIO/Common/NetSvrManager.h @@ -51,7 +51,7 @@ class CNetSvrManager : public CIo_List_Manager hashipport2tcpsslserver tcp_ssl_service_map_; #endif - std::mutex list_mutex_; + std::recursive_mutex list_mutex_; }; using App_NetSvrManager = PSS_singleton;