empty list of shmem regions if none found

This commit is contained in:
karenzshea 2018-04-13 11:08:01 +02:00 committed by Patrick Niklaus
parent 730d2b5ef2
commit e3b831364f
2 changed files with 5 additions and 3 deletions

View File

@ -117,10 +117,12 @@ template <typename Data> struct SharedMonitor
#endif
static void remove() { bi::shared_memory_object::remove(Data::name); }
static bool exists() {
static bool exists()
{
try
{
bi::shared_memory_object shmem_open = bi::shared_memory_object(bi::open_only, Data::name, bi::read_only);
bi::shared_memory_object shmem_open =
bi::shared_memory_object(bi::open_only, Data::name, bi::read_only);
}
catch (const bi::interprocess_exception &exception)
{

View File

@ -27,9 +27,9 @@ void deleteRegion(const storage::SharedRegionRegister::ShmKey key)
void listRegions()
{
osrm::util::Log() << "name\tshm key\ttimestamp\tsize";
if (!storage::SharedMonitor<storage::SharedRegionRegister>::exists())
{
osrm::util::Log() << "No shared memory regions found. Try running osrm-datastore";
return;
}
storage::SharedMonitor<storage::SharedRegionRegister> monitor;