Make a hard reset of named barrier mutexes on signal

This commit is contained in:
Michael Krasnyk 2016-12-21 13:34:45 +01:00
parent 0a2f934c87
commit df4231341f
No known key found for this signature in database
GPG Key ID: 49C12AD0F43D2108

View File

@ -1,3 +1,4 @@
#include "storage/shared_barriers.hpp"
#include "storage/storage.hpp"
#include "util/exception.hpp"
#include "util/log.hpp"
@ -7,6 +8,8 @@
#include <boost/filesystem.hpp>
#include <boost/program_options.hpp>
#include <csignal>
using namespace osrm;
// generate boost::program_options object for the routing part
@ -87,8 +90,21 @@ bool generateDataStoreOptions(const int argc,
return true;
}
static void CleanupSharedBarriers(int)
{ // Here the lock state of named mutexes is unknown, make a hard cleanup
osrm::storage::SharedBarriers::resetCurrentRegions();
osrm::storage::SharedBarriers::resetRegions1();
osrm::storage::SharedBarriers::resetRegions2();
}
int main(const int argc, const char *argv[]) try
{
int signals[] = {SIGTERM, SIGSEGV, SIGINT, SIGILL, SIGABRT, SIGFPE};
for (auto sig : signals)
{
std::signal(sig, CleanupSharedBarriers);
}
util::LogPolicy::GetInstance().Unmute();
boost::filesystem::path base_path;
@ -135,4 +151,4 @@ catch (const std::bad_alloc &e)
util::Log(logERROR) << "Please provide more memory or disable locking the virtual "
"address space (note: this makes OSRM swap, i.e. slow)";
return EXIT_FAILURE;
}
}