Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
taocp committed Nov 7, 2016
2 parents bcf7aac + 48d31cd commit bc98363
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
7 changes: 3 additions & 4 deletions build_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ VERSION_ADDR="https://github.com/baidu/tera"

BUILD_DATE_TIME=`date`
BUILD_HOSTNAME=`hostname`
BUILD_GCC_VERSION=`gcc --version | head -n 1`

gen_info_template_header ()
{
Expand All @@ -25,16 +24,16 @@ gen_info_template_foot ()
echo "extern const char kBuildTime[] = \"$BUILD_DATE_TIME\";"
echo "extern const char kBuilderName[] = \"$USER\";"
echo "extern const char kHostName[] = \"$BUILD_HOSTNAME\";"
echo "extern const char kCompiler[] = \"$BUILD_GCC_VERSION\";"
echo "extern const char kCompiler[] = __VERSION__;"
}

gen_info_print_template ()
{
echo "std::string SystemVersionInfo() {"
echo " std::stringstream ss;"
echo " ss << \"===== Version Info ===== \" << std::endl;"
echo " ss << \"Version: master\" << std::endl;"
echo " ss << \"Address: https://github.com/baidu/tera\" << std::endl;"
echo " ss << \"Version: $VERSION_INFO\" << std::endl;"
echo " ss << \"Address: $VERSION_ADDR\" << std::endl;"
echo " ss << std::endl;"
echo " ss << \"===== Git Info ===== \" << std::endl;"
echo " ss << kGitInfo << std::endl;"
Expand Down
16 changes: 12 additions & 4 deletions src/leveldb/util/nfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "util/hash.h"
#include "util/mutexlock.h"
#include "util/string_ext.h"
#include "../common/timer.h"
#include "../utils/counter.h"

namespace leveldb {
Expand Down Expand Up @@ -234,6 +235,7 @@ int32_t Nfs::CreateDirectory(const std::string& name) {
if (0 != (*nfsAccess)(path.c_str(), F_OK) && (*nfsGetErrno)() == ENOENT) {
if (0 != (*nfsMkdir)(path.c_str()) && (*nfsGetErrno)() != EEXIST) {
errno = (*nfsGetErrno)();
fprintf(stderr, "[%s] Createdir %s fail: %d\n", common::timer::get_curtime_str().c_str(), name.c_str(), errno);
return -1;
}
}
Expand All @@ -245,20 +247,23 @@ int32_t Nfs::DeleteDirectory(const std::string& name) {
int32_t retval = (*nfsRmdir)(name.c_str());
if (retval != 0) {
errno = (*nfsGetErrno)();
fprintf(stderr, "[%s] DeleteDirectory %s fail: %d\n", common::timer::get_curtime_str().c_str(), name.c_str(), errno);
}
return retval;
}
int32_t Nfs::Exists(const std::string& filename) {
int32_t retval = (*nfsAccess)(filename.c_str(), F_OK);
if (retval != 0) {
errno = (*nfsGetErrno)();
fprintf(stderr, "[%s] Exists %s fail: %d\n", common::timer::get_curtime_str().c_str(), filename.c_str(), errno);
}
return retval;
}
int32_t Nfs::Delete(const std::string& filename) {
int32_t retval = (*nfsUnlink)(filename.c_str());
if (retval != 0) {
errno = (*nfsGetErrno)();
fprintf(stderr, "[%s] Delete %s fail: %d\n", common::timer::get_curtime_str().c_str(), filename.c_str(), errno);
}
return retval;
}
Expand All @@ -269,13 +274,15 @@ int32_t Nfs::GetFileSize(const std::string& filename, uint64_t* size) {
*size = fileinfo.st_size;
} else {
errno = (*nfsGetErrno)();
fprintf(stderr, "[%s] Getfilesize %s fail: %d\n", common::timer::get_curtime_str().c_str(), filename.c_str(), errno);
}
return retval;
}
int32_t Nfs::Rename(const std::string& from, const std::string& to) {
int32_t retval = (*nfsRename)(from.c_str(), to.c_str());
if (retval != 0) {
errno = (*nfsGetErrno)();
fprintf(stderr, "[%s] Rename %s to %s fail: %d\n", common::timer::get_curtime_str().c_str(), from.c_str(), to.c_str(), errno);
}
return retval;
}
Expand All @@ -292,6 +299,7 @@ DfsFile* Nfs::OpenFile(const std::string& filename, int32_t flags) {
return new NFile(file, filename);
}
errno = (*nfsGetErrno)();
fprintf(stderr, "[%s] Openfile %s fail: %d\n", common::timer::get_curtime_str().c_str(), filename.c_str(), errno);
return NULL;
}

Expand All @@ -303,8 +311,8 @@ int32_t Nfs::ListDirectory(const std::string& path,
std::vector<std::string>* result) {
nfs::NFSDIR* dir = (*nfsOpendir)(path.c_str());
if (NULL == dir) {
fprintf(stderr, "Opendir %s fail\n", path.c_str());
errno = (*nfsGetErrno)();
fprintf(stderr, "[%s] Opendir %s fail: %d\n", common::timer::get_curtime_str().c_str(), path.c_str(), errno);
return -1;
}
struct ::dirent* dir_info = NULL;
Expand All @@ -314,9 +322,9 @@ int32_t Nfs::ListDirectory(const std::string& path,
result->push_back(pathname);
}
}
if (0 != (*nfsGetErrno)()) {
fprintf(stderr, "List %s error: %d\n", path.c_str(), (*nfsGetErrno)());
errno = (*nfsGetErrno)();
errno = (*nfsGetErrno)();
if (0 != errno) {
fprintf(stderr, "[%s] List %s error: %d\n", common::timer::get_curtime_str().c_str(), path.c_str(), errno);
(*nfsClosedir)(dir);
return -1;
}
Expand Down

0 comments on commit bc98363

Please sign in to comment.