File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -27,7 +27,11 @@ void deleteRegion(const storage::SharedRegionRegister::ShmKey key)
2727
2828void 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 )
You can’t perform that action at this time.
0 commit comments