Skip to content

Commit

Permalink
revert 63d87f8
Browse files Browse the repository at this point in the history
  • Loading branch information
garryyan committed Jun 20, 2017
1 parent 161e079 commit 0aa1d27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 32 deletions.
2 changes: 1 addition & 1 deletion mars/comm/dns/dns.cc
Expand Up @@ -259,7 +259,7 @@ bool DNS::GetHostByName(const std::string& _host_name, std::vector<std::string>&
if (kGetIPTimeout == it->status || kGetIPCancel == it->status || kGetIPFail == it->status) {
if (_breaker) _breaker->dnsstatus = NULL;

xinfo2(TSF "dns get ip status:%_ host:%_", it->status, it->host_name);
xinfo2(TSF "dns get ip status:%_ host:%_, func:%_", it->status, it->host_name, it->dns_func);
sg_dnsinfo_vec.erase(it);
return false;
}
Expand Down
35 changes: 4 additions & 31 deletions mars/log/src/appender.cc
Expand Up @@ -79,7 +79,6 @@ static TAppenderMode sg_mode = kAppednerAsync;
static std::string sg_logdir;
static std::string sg_cache_logdir;
static std::string sg_logfileprefix;
static std::string sg_pub_key;

static Mutex sg_mutex_log_file;
static FILE* sg_logfile = NULL;
Expand Down Expand Up @@ -252,19 +251,6 @@ static void __make_logfilename(const timeval& _tv, const std::string& _logdir, c
_filepath[_len - 1] = '\0';
}

static std::string& __get_mmap_filepath(const std::string& _cachedir, const std::string& _logdir, const std::string& _nameprefix) {
static std::string s_mmap_filepath;
if (!s_mmap_filepath.empty()) {
return s_mmap_filepath;
}

char mmap_file_path[1024] = {0};
snprintf(mmap_file_path, sizeof(mmap_file_path), "%s/%s.mmap2", _cachedir.empty()?_logdir.c_str():_cachedir.c_str(), _nameprefix.c_str());

s_mmap_filepath = mmap_file_path;
return s_mmap_filepath;
}

static void __del_files(const std::string& _forder_path) {

boost::filesystem::path path(_forder_path);
Expand Down Expand Up @@ -649,21 +635,6 @@ static void __appender_sync(const XLoggerInfo* _info, const char* _log) {
static void __appender_async(const XLoggerInfo* _info, const char* _log) {
ScopedLock lock(sg_mutex_buffer_async);
if (NULL == sg_log_buff) return;

if (sg_mmmap_file.is_open() && !sg_mmmap_file.operator!()
&& !boost::filesystem::exists(__get_mmap_filepath(sg_cache_logdir, sg_logdir, sg_logfileprefix))) {

__writetips2file("[F]mmap file is deleted! recreate it.\n");
CloseMmapFile(sg_mmmap_file);
delete sg_log_buff;

if (OpenMmapFile(__get_mmap_filepath(sg_cache_logdir, sg_logdir, sg_logfileprefix).c_str(), kBufferBlockLength, sg_mmmap_file)) {
sg_log_buff = new LogBuffer(sg_mmmap_file.data(), kBufferBlockLength, true, sg_pub_key.c_str());
} else {
char* buffer = new char[kBufferBlockLength];
sg_log_buff = new LogBuffer(buffer, kBufferBlockLength, true, sg_pub_key.c_str());
}
}

char temp[16*1024] = {0}; //tell perry,ray if you want modify size.
PtrBuffer log_buff(temp, 0, sizeof(temp));
Expand Down Expand Up @@ -846,8 +817,11 @@ void appender_open(TAppenderMode _mode, const char* _dir, const char* _nameprefi

tick.gettickcount();

char mmap_file_path[512] = {0};
snprintf(mmap_file_path, sizeof(mmap_file_path), "%s/%s.mmap2", sg_cache_logdir.empty()?_dir:sg_cache_logdir.c_str(), _nameprefix);

bool use_mmap = false;
if (OpenMmapFile(__get_mmap_filepath(sg_cache_logdir, _dir, _nameprefix).c_str(), kBufferBlockLength, sg_mmmap_file)) {
if (OpenMmapFile(mmap_file_path, kBufferBlockLength, sg_mmmap_file)) {
sg_log_buff = new LogBuffer(sg_mmmap_file.data(), kBufferBlockLength, true, _pub_key);
use_mmap = true;
} else {
Expand All @@ -868,7 +842,6 @@ void appender_open(TAppenderMode _mode, const char* _dir, const char* _nameprefi
ScopedLock lock(sg_mutex_log_file);
sg_logdir = _dir;
sg_logfileprefix = _nameprefix;
sg_pub_key = _pub_key;
sg_log_close = false;
appender_setmode(_mode);
lock.unlock();
Expand Down

0 comments on commit 0aa1d27

Please sign in to comment.