From d41316bc0ff5738e5108b6ed057a2dd82804a054 Mon Sep 17 00:00:00 2001 From: Dhruba Borthakur Date: Sat, 18 Aug 2012 00:26:50 -0700 Subject: [PATCH] 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 --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1635566ad..d8c3f0ce9 100644 --- a/Makefile +++ b/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.