mirror of
https://github.com/caozhiyi/CppNet.git
synced 2026-01-26 16:30:05 +08:00
fix only thread active bug.
This commit is contained in:
10
base/Log.cpp
10
base/Log.cpp
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user