Skip to content

Commit

Permalink
Improve support of large log file on 32-bit host (#308)
Browse files Browse the repository at this point in the history
* Better support large log file when -D_FILE_OFFSET_BITS=64 on 32-bit host

* Use off_t to define log file size uniformly

Cherry-pick: 39e5c72
  • Loading branch information
ligewei authored and chenshuo committed Jan 18, 2018
1 parent 6a29505 commit 65e4dc4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion muduo/base/AsyncLogging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using namespace muduo;

AsyncLogging::AsyncLogging(const string& basename,
size_t rollSize,
off_t rollSize,
int flushInterval)
: flushInterval_(flushInterval),
running_(false),
Expand Down
4 changes: 2 additions & 2 deletions muduo/base/AsyncLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AsyncLogging : noncopyable
public:

AsyncLogging(const string& basename,
size_t rollSize,
off_t rollSize,
int flushInterval = 3);

~AsyncLogging()
Expand Down Expand Up @@ -57,7 +57,7 @@ class AsyncLogging : noncopyable
const int flushInterval_;
std::atomic<bool> running_;
string basename_;
size_t rollSize_;
off_t rollSize_;
muduo::Thread thread_;
muduo::CountDownLatch latch_;
muduo::MutexLock mutex_;
Expand Down
4 changes: 2 additions & 2 deletions muduo/base/FileUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ class AppendFile : noncopyable

void flush();

size_t writtenBytes() const { return writtenBytes_; }
off_t writtenBytes() const { return writtenBytes_; }

private:

size_t write(const char* logline, size_t len);

FILE* fp_;
char buffer_[64*1024];
size_t writtenBytes_;
off_t writtenBytes_;
};
}

Expand Down
2 changes: 1 addition & 1 deletion muduo/base/LogFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using namespace muduo;

LogFile::LogFile(const string& basename,
size_t rollSize,
off_t rollSize,
bool threadSafe,
int flushInterval,
int checkEveryN)
Expand Down
4 changes: 2 additions & 2 deletions muduo/base/LogFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class LogFile : noncopyable
{
public:
LogFile(const string& basename,
size_t rollSize,
off_t rollSize,
bool threadSafe = true,
int flushInterval = 3,
int checkEveryN = 1024);
Expand All @@ -34,7 +34,7 @@ class LogFile : noncopyable
static string getLogFileName(const string& basename, time_t* now);

const string basename_;
const size_t rollSize_;
const off_t rollSize_;
const int flushInterval_;
const int checkEveryN_;

Expand Down
2 changes: 1 addition & 1 deletion muduo/base/tests/AsyncLogging_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <sys/resource.h>
#include <unistd.h>

int kRollSize = 500*1000*1000;
off_t kRollSize = 500*1000*1000;

muduo::AsyncLogging* g_asyncLog = NULL;

Expand Down

0 comments on commit 65e4dc4

Please sign in to comment.