Recover from stale mutexes with force unlocking and retry

This commit is contained in:
Patrick Niklaus
2016-10-12 21:26:59 +02:00
committed by Patrick Niklaus
parent caa7c994a0
commit 81c5cba0e5
6 changed files with 145 additions and 28 deletions
@@ -150,7 +150,7 @@ class SharedDataFacade final : public BaseDataFacade
if (!boost::filesystem::exists(file_index_path))
{
util::SimpleLogger().Write(logDEBUG) << "Leaf file name " << file_index_path.string();
throw util::exception("Could not load leaf index file. "
throw util::exception("Could not load " + file_index_path.string() +
"Is any data loaded into shared memory?");
}
+13 -1
View File
@@ -19,11 +19,23 @@ struct SharedBarriers
{
}
static void resetCurrentRegions()
{
boost::interprocess::named_sharable_mutex::remove("current_regions");
}
static void resetRegions1()
{
boost::interprocess::named_sharable_mutex::remove("regions_1");
}
static void resetRegions2()
{
boost::interprocess::named_sharable_mutex::remove("regions_2");
}
boost::interprocess::named_upgradable_mutex current_regions_mutex;
boost::interprocess::named_sharable_mutex regions_1_mutex;
boost::interprocess::named_sharable_mutex regions_2_mutex;
};
}
}
+9 -1
View File
@@ -42,7 +42,15 @@ class Storage
{
public:
Storage(StorageConfig config);
int Run();
enum ReturnCode
{
Ok,
Error,
Retry
};
ReturnCode Run(int max_wait);
private:
StorageConfig config;