fix only thread active bug.

This commit is contained in:
caozhiyi
2019-09-02 21:41:17 +08:00
parent 8518c3354f
commit 132da0bc74
2 changed files with 11 additions and 7 deletions

View File

@@ -54,7 +54,7 @@ LogLevel CLog::GetLogLevel() {
}
void CLog::LogDebug(const char* file, int line, const char* log...) {
if (!_stop) {
if (_stop) {
return;
}
if (_log_level <= LOG_DEBUG_LEVEL) {
@@ -66,7 +66,7 @@ void CLog::LogDebug(const char* file, int line, const char* log...) {
}
void CLog::LogInfo(const char* file, int line, const char* log...) {
if (!_stop) {
if (_stop) {
return;
}
if (_log_level <= LOG_INFO_LEVEL) {
@@ -78,7 +78,7 @@ void CLog::LogInfo(const char* file, int line, const char* log...) {
}
void CLog::LogWarn(const char* file, int line, const char* log...) {
if (!_stop) {
if (_stop) {
return;
}
if (_log_level <= LOG_WARN_LEVEL) {
@@ -90,7 +90,7 @@ void CLog::LogWarn(const char* file, int line, const char* log...) {
}
void CLog::LogError(const char* file, int line, const char* log...) {
if (!_stop) {
if (_stop) {
return;
}
if (_log_level <= LOG_ERROR_LEVEL) {
@@ -102,7 +102,7 @@ void CLog::LogError(const char* file, int line, const char* log...) {
}
void CLog::LogFatal(const char* file, int line, const char* log...) {
if (!_stop) {
if (_stop) {
return;
}
if (_log_level <= LOG_FATAL_LEVEL) {

View File

@@ -23,7 +23,9 @@ CCppNetImpl::CCppNetImpl() : _per_epoll_handle(true) {
}
CCppNetImpl::~CCppNetImpl() {
_thread_vec.clear();
_actions_map.clear();
_accept_socket.clear();
}
void CCppNetImpl::Init(uint32_t thread_num, bool per_handl_thread) {
@@ -150,12 +152,14 @@ bool CCppNetImpl::ListenAndAccept(uint16_t port, std::string ip, uint32_t listen
}
for (auto iter = _actions_map.begin(); iter != _actions_map.end(); ++iter) {
base::CMemSharePtr<CAcceptSocket> accept_socket = base::MakeNewSharedPtr<CAcceptSocket>(&_pool, _actions_map.begin()->second);
base::CMemSharePtr<CAcceptSocket> accept_socket = base::MakeNewSharedPtr<CAcceptSocket>(&_pool, iter->second);
if (!accept_socket->Bind(port, ip)) {
base::LOG_ERROR("bind failed. port : %d, ip : %s ", port, ip.c_str());
return false;
}
if (!accept_socket->Listen(listen_num)) {
base::LOG_ERROR("listen failed. port : %d, ip : %s ", port, ip.c_str());
return false;
}