Skip to content

Commit

Permalink
log err instead of throwing when no shmem regions found
Browse files Browse the repository at this point in the history
  • Loading branch information
karenzshea authored and Patrick Niklaus committed Apr 13, 2018
1 parent 16abee1 commit 730d2b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 11 additions & 0 deletions include/storage/shared_monitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ template <typename Data> struct SharedMonitor
#endif

static void remove() { bi::shared_memory_object::remove(Data::name); }
static bool exists() {
try
{
bi::shared_memory_object shmem_open = bi::shared_memory_object(bi::open_only, Data::name, bi::read_only);
}
catch (const bi::interprocess_exception &exception)
{
return false;
}
return true;
}

private:
#if USE_BOOST_INTERPROCESS_CONDITION
Expand Down
9 changes: 6 additions & 3 deletions src/tools/store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ void deleteRegion(const storage::SharedRegionRegister::ShmKey key)

void listRegions()
{

if (!storage::SharedMonitor<storage::SharedRegionRegister>::exists())
{
osrm::util::Log() << "No shared memory regions found. Try running osrm-datastore";
return;
}
storage::SharedMonitor<storage::SharedRegionRegister> monitor;
std::vector<std::string> names;
const auto &shared_register = monitor.data();
Expand Down Expand Up @@ -105,8 +109,7 @@ bool generateDataStoreOptions(const int argc,
boost::program_options::value<bool>(&list_datasets)
->default_value(false)
->implicit_value(true),
"Name of the dataset to load into memory. This allows having multiple datasets in memory "
"at the same time.") //
"List all OSRM datasets currently in memory") //
("only-metric",
boost::program_options::value<bool>(&only_metric)
->default_value(false)
Expand Down

0 comments on commit 730d2b5

Please sign in to comment.