Prevent concurrent multiple opens of leveldb database.
Summary: The fcntl call cannot detect lock conflicts when invoked multiple times from the same thread. Use a static lockedFile Set to record the paths that are locked. A lockfile request checks to see if htis filename already exists in lockedFiles, if so, then it triggers an error. Otherwise, it inserts the filename in the lockedFiles Set. A unlock file request verifies that the filename is in the lockedFiles set and removes it from lockedFiles set. Test Plan: unit test attached Reviewers: heyongqiang Reviewed By: heyongqiang Differential Revision: https://reviews.facebook.net/D4755
This commit is contained in:
parent
f3ee54526f
commit
d41316bc0f
5
Makefile
5
Makefile
@ -56,7 +56,6 @@ TESTS = \
|
||||
write_batch_test \
|
||||
filelock_test
|
||||
|
||||
|
||||
TOOLS = \
|
||||
manifest_dump \
|
||||
leveldb_shell \
|
||||
@ -198,6 +197,10 @@ sst_dump: tools/sst_dump.o $(LIBOBJECTS)
|
||||
$(VERSIONFILE): build_detect_version
|
||||
$(shell ./build_detect_platform build_config.mk)
|
||||
|
||||
filelock_test: util/filelock_test.o $(LIBOBJECTS) $(TESTHARNESS)
|
||||
$(CXX) util/filelock_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
|
||||
|
||||
|
||||
ifeq ($(PLATFORM), IOS)
|
||||
# For iOS, create universal object files to be used on both the simulator and
|
||||
# a device.
|
||||
|
Loading…
Reference in New Issue
Block a user