Address PR comments

This commit is contained in:
Patrick Niklaus 2018-04-05 11:24:52 +00:00 committed by Patrick Niklaus
parent c2532b1589
commit c7daa521ad
3 changed files with 17 additions and 15 deletions

View File

@ -232,8 +232,6 @@ struct SharedRegionRegister
} }
} }
void Deregister(const RegionID key) { regions[key] = SharedRegion{}; }
const auto &GetRegion(const RegionID key) const { return regions[key]; } const auto &GetRegion(const RegionID key) const { return regions[key]; }
auto &GetRegion(const RegionID key) { return regions[key]; } auto &GetRegion(const RegionID key) { return regions[key]; }

View File

@ -117,7 +117,7 @@ int Storage::Run(int max_wait, const std::string &dataset_name)
util::UnbufferedLog() << "ok."; util::UnbufferedLog() << "ok.";
} }
util::Log() << "Loading data into " << shm_key; util::Log() << "Loading data into " << static_cast<int>(shm_key);
// Populate a memory layout into stack memory // Populate a memory layout into stack memory
DataLayout layout; DataLayout layout;
@ -176,8 +176,8 @@ int Storage::Run(int max_wait, const std::string &dataset_name)
} }
} }
util::Log() << "All data loaded. Notify all client about new data in " << shm_key util::Log() << "All data loaded. Notify all client about new data in "
<< " with timestamp " << next_timestamp; << static_cast<int>(shm_key) << " with timestamp " << next_timestamp;
monitor.notify_all(); monitor.notify_all();
// SHMCTL(2): Mark the segment to be destroyed. The segment will actually be destroyed // SHMCTL(2): Mark the segment to be destroyed. The segment will actually be destroyed
@ -185,7 +185,7 @@ int Storage::Run(int max_wait, const std::string &dataset_name)
if (in_use_key != SharedRegionRegister::MAX_SHM_KEYS && if (in_use_key != SharedRegionRegister::MAX_SHM_KEYS &&
storage::SharedMemory::RegionExists(in_use_key)) storage::SharedMemory::RegionExists(in_use_key))
{ {
util::UnbufferedLog() << "Marking old shared memory region " << in_use_key util::UnbufferedLog() << "Marking old shared memory region " << static_cast<int>(in_use_key)
<< " for removal... "; << " for removal... ";
// aquire a handle for the old shared memory region before we mark it for deletion // aquire a handle for the old shared memory region before we mark it for deletion

View File

@ -21,7 +21,7 @@ void deleteRegion(const storage::SharedRegionRegister::ShmKey key)
{ {
if (storage::SharedMemory::RegionExists(key) && !storage::SharedMemory::Remove(key)) if (storage::SharedMemory::RegionExists(key) && !storage::SharedMemory::Remove(key))
{ {
util::Log(logWARNING) << "could not delete shared memory region " << key; util::Log(logWARNING) << "could not delete shared memory region " << static_cast<int>(key);
} }
} }
@ -32,12 +32,14 @@ void listRegions()
std::vector<std::string> names; std::vector<std::string> names;
const auto &shared_register = monitor.data(); const auto &shared_register = monitor.data();
shared_register.List(std::back_inserter(names)); shared_register.List(std::back_inserter(names));
osrm::util::Log() << "name\tshm key\ttimestamp"; osrm::util::Log() << "name\tshm key\ttimestamp\tsize";
for (const auto &name : names) for (const auto &name : names)
{ {
auto id = shared_register.Find(name); auto id = shared_register.Find(name);
auto region = shared_register.GetRegion(id); auto region = shared_register.GetRegion(id);
osrm::util::Log() << name << "\t" << (int)region.shm_key << "\t" << region.timestamp; auto shm = osrm::storage::makeSharedMemory(region.shm_key);
osrm::util::Log() << name << "\t" << static_cast<int>(region.shm_key) << "\t"
<< region.timestamp << "\t" << shm->Size();
} }
} }
@ -77,12 +79,14 @@ bool generateDataStoreOptions(const int argc,
{ {
// declare a group of options that will be allowed only on command line // declare a group of options that will be allowed only on command line
boost::program_options::options_description generic_options("Options"); boost::program_options::options_description generic_options("Options");
generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")( generic_options.add_options() //
"verbosity,l", ("version,v", "Show version") //
("help,h", "Show this help message") //
("verbosity,l",
boost::program_options::value<std::string>(&verbosity)->default_value("INFO"), boost::program_options::value<std::string>(&verbosity)->default_value("INFO"),
std::string("Log verbosity level: " + util::LogPolicy::GetLevels()).c_str())( std::string("Log verbosity level: " + util::LogPolicy::GetLevels()).c_str()) //
"remove-locks,r", "Remove locks")("spring-clean,s", ("remove-locks,r", "Remove locks") //
"Spring-cleaning all shared memory regions"); ("spring-clean,s", "Spring-cleaning all shared memory regions");
// declare a group of options that will be allowed both on command line // declare a group of options that will be allowed both on command line
// as well as in a config file // as well as in a config file