Skip to content

Commit

Permalink
Merge pull request markparticle#23 from markparticle/dev_mark
Browse files Browse the repository at this point in the history
 🐛 fig bug
  • Loading branch information
markparticle committed Jul 7, 2020
2 parents 19d872f + bd6cc94 commit 152199f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
3 changes: 0 additions & 3 deletions code/log/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,9 @@ void Log::init(int level = 1, const char* path, const char* suffix,
}
assert(fp_ != nullptr);
}

}

void Log::write(int level, const char *format, ...) {
if(isAsync_) { deque_->flush(); }
struct timeval now = {0, 0};
gettimeofday(&now, nullptr);
time_t tSec = now.tv_sec;
Expand Down Expand Up @@ -147,7 +145,6 @@ void Log::write(int level, const char *format, ...) {
fputs(buff_.Peek(), fp_);
}
buff_.RetrieveAll();

}
}

Expand Down
1 change: 1 addition & 0 deletions code/log/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Log {
if (log->IsOpen() && log->GetLevel() <= level) {\
log->write(level, format, ##__VA_ARGS__); \
log->flush();\
if(isAsync_) { deque_->flush(); } \
}\
} while(0);

Expand Down
2 changes: 1 addition & 1 deletion code/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int main() {
WebServer server(
1316, 3, 5000, false, /* 端口 ET模式 timeoutMs 优雅退出 */
3306, "root", "root", "webserver", /* Mysql配置 */
100, 6, true, 0, 0); /* 连接池数量 线程池数量 日志开关 日志等级 日志异步队列容量 */
12, 6, false, 0, 1024); /* 连接池数量 线程池数量 日志开关 日志等级 日志异步队列容量 */
server.Start();
}

2 changes: 2 additions & 0 deletions code/server/webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ bool WebServer::InitSocket_() {
}

int optval = 1;
/* 端口复用 */
/* 。但是,这些套接字并不是所有都能读取信息,只有最后一个套接字会正常接收数据。 */
ret = setsockopt(listenFd_, SOL_SOCKET, SO_REUSEADDR, (const void*)&optval, sizeof(int));
if(ret == -1) {
LOG_ERROR("set socket setsockopt error !");
Expand Down

0 comments on commit 152199f

Please sign in to comment.