Skip to content

Commit

Permalink
fix code smell.
Browse files Browse the repository at this point in the history
  • Loading branch information
freeeyes committed Oct 19, 2023
1 parent 2396110 commit a04eb9e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
35 changes: 21 additions & 14 deletions PSS_ASIO/Message/ModuleLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,15 @@ void CWorkThreadLogic::add_thread_session(uint32 connect_id, shared_ptr<ISession

module_logic->do_thread_module_logic(source, recv_packet, send_packet);
});

#ifdef GCOV_TEST
//测试发送链接建立消息
if (connect_id == 2)
{
auto bridge_packet = std::make_shared<CMessage_Packet>();
send_io_bridge_message_fail(connect_id, bridge_packet, session);
}
#endif
}

void CWorkThreadLogic::delete_thread_session(uint32 connect_id, shared_ptr<ISession> session)
Expand Down Expand Up @@ -411,8 +420,6 @@ int CWorkThreadLogic::assignation_thread_module_logic(const uint32 connect_id, c
//测试连接自检
uint32 check_timeout = 120;
run_check_task(check_timeout);

//send_io_buffer();
#endif
return 0;
}
Expand Down Expand Up @@ -712,6 +719,16 @@ bool CWorkThreadLogic::set_io_bridge_connect_id(uint32 from_io_connect_id, uint3
}
}

void CWorkThreadLogic::send_io_bridge_message_fail(uint32 connect_id, std::shared_ptr<CMessage_Packet> bridge_packet, shared_ptr<ISession> session)
{
vector<std::shared_ptr<CMessage_Packet>> message_error_list;
bridge_packet->command_id_ = LOGIC_IOTOIO_DATA_ERROR;
message_error_list.emplace_back(bridge_packet);

//添加消息处理
assignation_thread_module_logic(connect_id, message_error_list, session);
}

int CWorkThreadLogic::do_io_bridge_data(uint32 connect_id, uint32 io_bridge_connect_id_, CSessionBuffer& session_recv_buffer, std::size_t length, shared_ptr<ISession> session)
{
int ret = 0;
Expand All @@ -722,12 +739,7 @@ int CWorkThreadLogic::do_io_bridge_data(uint32 connect_id, uint32 io_bridge_conn
if (false == send_io_bridge_message(io_bridge_connect_id_, bridge_packet))
{
//发送失败,将数据包会给业务逻辑去处理
vector<std::shared_ptr<CMessage_Packet>> message_error_list;
bridge_packet->command_id_ = LOGIC_IOTOIO_DATA_ERROR;
message_error_list.emplace_back(bridge_packet);

//添加消息处理
assignation_thread_module_logic(connect_id, message_error_list, session);
send_io_bridge_message_fail(connect_id, bridge_packet, session);
ret = 1;
}
else
Expand All @@ -738,12 +750,7 @@ int CWorkThreadLogic::do_io_bridge_data(uint32 connect_id, uint32 io_bridge_conn
else
{
//发送失败,将数据包会给业务逻辑去处理
vector<std::shared_ptr<CMessage_Packet>> message_error_list;
bridge_packet->command_id_ = LOGIC_IOTOIO_DATA_ERROR;
message_error_list.emplace_back(bridge_packet);

//添加消息处理
assignation_thread_module_logic(connect_id, message_error_list, session);
send_io_bridge_message_fail(connect_id, bridge_packet, session);
ret = 2;
}

Expand Down
1 change: 1 addition & 0 deletions PSS_ASIO/Message/ModuleLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class CWorkThreadLogic
private:
void send_io_buffer_to_session(uint32 connect_id, std::shared_ptr<ISession> session, std::shared_ptr<CMessage_Packet> format_packet) const;
void do_work_thread_timeout(uint16 work_thread_id, uint16 last_dispose_command_id, int work_thread_timeout);
void send_io_bridge_message_fail(uint32 connect_id, std::shared_ptr<CMessage_Packet> bridge_packet, shared_ptr<ISession> session);

using hashmappluginworkthread = unordered_map<uint32, shared_ptr<CModuleLogic>>;
using hashmaplogictimer = unordered_map<uint64, brynet::Timer::WeakPtr>;
Expand Down

0 comments on commit a04eb9e

Please sign in to comment.