log err instead of throwing when no shmem regions found
This commit is contained in:
		
							parent
							
								
									cf505386f9
								
							
						
					
					
						commit
						f8d6e4750a
					
				@ -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
 | 
			
		||||
 | 
			
		||||
@ -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();
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user