Skip to content

Commit f8d6e47

Browse files
karenzsheaTheMarex
authored andcommitted
log err instead of throwing when no shmem regions found
1 parent cf50538 commit f8d6e47

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

include/storage/shared_monitor.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ template <typename Data> struct SharedMonitor
117117
#endif
118118

119119
static void remove() { bi::shared_memory_object::remove(Data::name); }
120+
static bool exists() {
121+
try
122+
{
123+
bi::shared_memory_object shmem_open = bi::shared_memory_object(bi::open_only, Data::name, bi::read_only);
124+
}
125+
catch (const bi::interprocess_exception &exception)
126+
{
127+
return false;
128+
}
129+
return true;
130+
}
120131

121132
private:
122133
#if USE_BOOST_INTERPROCESS_CONDITION

src/tools/store.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ void deleteRegion(const storage::SharedRegionRegister::ShmKey key)
2727

2828
void listRegions()
2929
{
30-
30+
if (!storage::SharedMonitor<storage::SharedRegionRegister>::exists())
31+
{
32+
osrm::util::Log() << "No shared memory regions found. Try running osrm-datastore";
33+
return;
34+
}
3135
storage::SharedMonitor<storage::SharedRegionRegister> monitor;
3236
std::vector<std::string> names;
3337
const auto &shared_register = monitor.data();
@@ -105,8 +109,7 @@ bool generateDataStoreOptions(const int argc,
105109
boost::program_options::value<bool>(&list_datasets)
106110
->default_value(false)
107111
->implicit_value(true),
108-
"Name of the dataset to load into memory. This allows having multiple datasets in memory "
109-
"at the same time.") //
112+
"List all OSRM datasets currently in memory") //
110113
("only-metric",
111114
boost::program_options::value<bool>(&only_metric)
112115
->default_value(false)

0 commit comments

Comments
 (0)