Open peng-yq opened 4 months ago
main.cpp
int main() { /* 守护进程 后台运行 */ //daemon(1, 0); WebServer server( 1316, 3, 60000, false, /* 端口 ET模式 timeoutMs 优雅退出 */ 3306, "root", "root", "webserver", /* Mysql配置 */ 12, 6, true, 1, 1024); /* 连接池数量 线程池数量 日志开关 日志等级 日志异步队列容量 */ server.Start(); }
webserver,cpp
Log::Instance()->init(logLevel, "./log", ".log", logQueSize);
log.cpp
void Log::init(int level = 1, const char* path, const char* suffix, int maxQueueSize) { isOpen_ = true; level_ = level; if(maxQueueSize > 0) { isAsync_ = true; if(!deque_) { unique_ptr<BlockDeque<std::string>> newDeque(new BlockDeque<std::string>); deque_ = move(newDeque); std::unique_ptr<std::thread> NewThread(new thread(FlushLogThread)); writeThread_ = move(NewThread); } } else { isAsync_ = false; } }
blockqueue.h
explicit BlockDeque(size_t MaxCapacity = 1000); template<class T> BlockDeque<T>::BlockDeque(size_t MaxCapacity) :capacity_(MaxCapacity) { assert(MaxCapacity > 0); isClose_ = false; }
当设置了 logQueSize > 0,实际的异步日志队列容量并不是设置的logQueSize,而是默认的1000
unique_ptr<BlockDeque<std::string>> newDeque(new BlockDeque<std::string>);
应该修改为
unique_ptr<BlockDeque<std::string>> newDeque(new BlockDeque<std::string>(logQueSize));
main.cpp
webserver,cpp
log.cpp
blockqueue.h
当设置了 logQueSize > 0,实际的异步日志队列容量并不是设置的logQueSize,而是默认的1000
应该修改为