there is one bug in master_udp when running in multi-threads daemon mode.

This commit is contained in:
Zheng Shuxin 2017-06-23 12:15:21 +08:00
parent 33966ab441
commit f5c499cc1a
2 changed files with 4 additions and 0 deletions

View File

@ -1,5 +1,6 @@
#pragma once
#include "master_base.hpp"
#include "../stdlib/locker.hpp"
namespace acl {
@ -50,6 +51,7 @@ protected:
private:
std::vector<socket_stream*> sstreams_;
locker locker_;
void close_sstreams(void);

View File

@ -179,6 +179,7 @@ void master_udp::thread_init(void *)
if (__mu->daemon_mode_)
{
ACL_VSTREAM** streams = acl_udp_server_streams();
__mu->locker_.lock();
if (streams != NULL)
{
for (int i = 0; streams[i] != NULL; i++)
@ -189,6 +190,7 @@ void master_udp::thread_init(void *)
__mu->sstreams_.push_back(ss);
}
}
__mu->locker_.unlock();
}
#endif
__mu->thread_on_init();