Fix ldb segfault and use static libsnappy for all builds

Summary:
Link statically against snappy, using the gvfs one for facebook
environments, and the bundled one otherwise.

In addition, fix a few minor segfaults in ldb when it couldn't open the
database, and update .gitignore to include a few other build artifacts.

Test Plan: make check

Reviewers: dhruba

Reviewed By: dhruba

CC: leveldb

Differential Revision: https://reviews.facebook.net/D6855
This commit is contained in:
Chip Turner 2012-11-20 16:14:04 -08:00
parent 7632fdb5cb
commit 879e45eb99
5 changed files with 22 additions and 7 deletions

7
.gitignore vendored
View File

@ -6,3 +6,10 @@ build_config.mk
*.so.*
*_test
db_bench
db_stress
ldb
leveldb_server
leveldb_shell
manifest_dump
sst_dump
util/build_version.cc

View File

@ -165,7 +165,7 @@ EOF
EOF
if [ "$?" = 0 ]; then
COMMON_FLAGS="$COMMON_FLAGS -DSNAPPY"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lsnappy -L./snappy/libs"
PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS ${SNAPPY_LDFLAGS:-./snappy/libs/libsnappy.a}"
fi
# Test whether zlib library is installed

View File

@ -24,8 +24,8 @@ if test "$USE_HDFS"; then
fi
# location of snappy headers and libraries
SNAPPY_INCLUDE=" -I ./snappy"
SNAPPY_LIBS=" -L./snappy/libs"
SNAPPY_INCLUDE=" -I $TOOLCHAIN_LIB_BASE/snappy/snappy-1.0.3/7518bbe/include"
SNAPPY_LIBS=" $TOOLCHAIN_LIB_BASE/snappy/snappy-1.0.3/7518bbe/lib/libsnappy.a"
# location of boost headers and libraries
THRIFT_INCLUDE=" -I $TOOLCHAIN_LIB_BASE/boost/boost-1.48.0/bef9365/include -std=gnu++0x"
@ -49,5 +49,6 @@ EXEC_LDFLAGS=" -Wl,--whole-archive $TOOLCHAIN_LIB_BASE/jemalloc/$TOOL_JEMALLOC/l
EXEC_LDFLAGS+="-Wl,--no-whole-archive $TOOLCHAIN_LIB_BASE/libunwind/libunwind-20100812_experimental/91ddd43/lib/libunwind.a"
EXEC_LDFLAGS+="$HDFSLIB $SNAPPY_LIBS $THRIFT_LIBS "
EXEC_LDFLAGS_SHARED="$SNAPPY_LIBS $TOOLCHAIN_LIB_BASE/jemalloc/$TOOL_JEMALLOC/lib/libjemalloc.so"
SNAPPY_LDFLAGS="$SNAPPY_LIBS"
export CC CXX AR RANLIB CFLAGS EXEC_LDFLAGS EXEC_LDFLAGS_SHARED
export CC CXX AR RANLIB CFLAGS EXEC_LDFLAGS EXEC_LDFLAGS_SHARED SNAPPY_LDFLAGS

View File

@ -315,6 +315,9 @@ void ReduceDBLevels::DoCommand() {
old_levels_ = old_level_num;
OpenDB();
if (!db_) {
return;
}
// Compact the whole DB to put all files to the highest level.
fprintf(stdout, "Compacting the db...\n");
db_->CompactRange(NULL, NULL);

View File

@ -44,10 +44,10 @@ public:
case EXEC_SUCCEED:
break;
case EXEC_FAILED:
ret.append("Failed.");
ret.append("Failed: ");
break;
case EXEC_NOT_STARTED:
ret.append("Not started.");
ret.append("Not started: ");
}
if (!message_.empty()) {
ret.append(message_);
@ -134,6 +134,10 @@ public:
OpenDB();
}
if (!db_) {
return;
}
DoCommand();
if (exec_state_.IsNotStarted()) {
exec_state_ = LDBCommandExecuteResult::SUCCEED("");