From b25a54c8b525fd33ade1663007e61bfe8e69b3f3 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Fri, 1 Mar 2019 15:31:43 -0800 Subject: [PATCH] Fixed race condition, where on Linux when you compact the DB, it may not unlock before it reopens --- microstack/ILibSimpleDataStore.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/microstack/ILibSimpleDataStore.c b/microstack/ILibSimpleDataStore.c index 8f6b597..9baa695 100644 --- a/microstack/ILibSimpleDataStore.c +++ b/microstack/ILibSimpleDataStore.c @@ -617,6 +617,9 @@ __EXPORT_TYPE int ILibSimpleDataStore_Compact(ILibSimpleDataStore dataStore) if (root->error == 0) { // Success in writing new temporary file +#ifdef _POSIX + flock(fileno(root->dataFile), LOCK_UN); +#endif fclose(root->dataFile); // Close the data store fclose(compacted); // Close the temporary data store