* udp释放修正
This commit is contained in:
+8
-2
@@ -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)
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user