Skip to content

Commit

Permalink
修复日志报错,以及编译中的一个warning
Browse files Browse the repository at this point in the history
  • Loading branch information
yedongfu committed Jul 3, 2021
1 parent cc2b614 commit 1487b51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions handy/codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ struct CodecBase {
virtual int tryDecode(Slice data, Slice &msg) = 0;
virtual void encode(Slice msg, Buffer &buf) = 0;
virtual CodecBase *clone() = 0;
virtual ~CodecBase() {};
};

//以\r\n结尾的消息
Expand Down
7 changes: 6 additions & 1 deletion handy/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <time.h>
#include <unistd.h>
#include <utility>
#include <thread>
#include "port_posix.h"

using namespace std;
Expand Down Expand Up @@ -93,7 +94,11 @@ void Logger::maybeRotate() {
return;
}
dup2(fd, fd_);
close(fd);
thread t([=]{
usleep(200 * 1000); // 睡眠200ms,参考leveldb做法
close(fd);
});
t.detach();
}

static thread_local uint64_t tid;
Expand Down

0 comments on commit 1487b51

Please sign in to comment.