* udp释放修正

This commit is contained in:
2026-03-03 14:23:40 +08:00
parent bdce08657c
commit 93129d0761
2 changed files with 10 additions and 3 deletions
+8 -2
View File
@@ -157,7 +157,6 @@ public:
}
~ServerUdpImp()
{
_ioContext.stop();
}
void _init(const asio::ip::address& addr, asio::ip::port_type port)
@@ -208,6 +207,11 @@ public:
#endif
_read();
}
void _stop()
{
_ioContext.stop();
}
};
//---------------------------------------Implement--------------------------------------
@@ -487,8 +491,10 @@ ServerUdp::ServerUdp()
ServerUdp::~ServerUdp()
{
delete _imp;
_imp->_stop();
// 先删除线程,等待执行完后,再删自己
delete _t;
delete _imp;
}
void ServerUdp::_thread_run(void* p)
+2 -1
View File
@@ -26,7 +26,8 @@ namespace dl
_t.join();
while (true)
{
if (_state != 0)
// 必须完成线程后,才能删除自己
if (_state == 1)
break;
std::this_thread::sleep_for(std::chrono::seconds(0));
}