Log helpful error message if mmap fails.

This commit is contained in:
Daniel Patterson 2016-12-07 11:42:13 -08:00 committed by Patrick Niklaus
parent 875f482203
commit 17e15033e1
3 changed files with 29 additions and 4 deletions

View File

@ -28,6 +28,7 @@
- fixed a bug that could result in inconsistent behaviour when collapsing instructions
- fixed a bug that could result in crashes when leaving a ferry directly onto a motorway ramp
- fixed a bug in the tile plugin that resulted in discovering invalid edges for connections
- improved error messages when missing files during traffic updates (#3114)
- Debug Tiles
- Added support for turn penalties
- Internals

View File

@ -3,6 +3,14 @@ Feature: osrm-contract command line options: invalid options
Background:
Given the profile "testbot"
And the node map
"""
a b
"""
And the ways
| nodes |
| ab |
And the data has been extracted
Scenario: osrm-contract - Non-existing option
When I try to run "osrm-contract --fly-me-to-the-moon"
@ -10,3 +18,11 @@ Feature: osrm-contract command line options: invalid options
And stderr should contain "option"
And stderr should contain "fly-me-to-the-moon"
And it should exit with an error
# This tests the error messages when you try to use --segment-speed-file,
# but osrm-extract has not been run with --generate-edge-lookup
Scenario: osrm-contract - Someone forgot --generate-edge-lookup on osrm-extract
When I try to run "osrm-contract --segment-speed-file /dev/null {processed_file}"
Then stderr should contain "Error while trying to mmap"
Then stderr should contain ".osrm.edge_penalties"
And it should exit with an error

View File

@ -521,10 +521,18 @@ EdgeID Contractor::LoadEdgeExpandedGraph(
using boost::interprocess::mapped_region;
using boost::interprocess::read_only;
const file_mapping mapping{filename.c_str(), read_only};
mapped_region region{mapping, read_only};
region.advise(mapped_region::advice_sequential);
return region;
try
{
const file_mapping mapping{filename.c_str(), read_only};
mapped_region region{mapping, read_only};
region.advise(mapped_region::advice_sequential);
return region;
}
catch (const std::exception &e)
{
util::Log(logERROR) << "Error while trying to mmap " + filename + ": " + e.what();
throw;
}
};
const auto edge_based_graph_region = mmap_file(edge_based_graph_filename);