Open Source Routing Machine - C++ backend
Go to file
Daniel J. Hofmann 3279cbac24 Extend compressed output lifetime till the async write function finishes.
This extends the compressed output vector's lifetime, as we issue an
asynchronous write operation that only receives a non-owning buffer to
the compressed data.

When the compressed output vector then goes out of scope, its destructor
is called and the data gets (potentially) destroyed. If the asynchronous
write happens afterwards, it's accessing data that is no longer there.

This is the reason for race conditions --- well, for undefined behavior
in general, but it manifests in the routed _sometimes_ not responding at
all.

The fix works like this: keep the compressed output associated with a
connection. Connections inherit from `std::enable_shared_from_this` and
issues a `shared_from_this()` call, passing a `std::shared_ptr` to the
asynchronous write function, thus extending their lifetime.

Connecitons thus manage their lifetime by themselves, extending it when
needed (and of course via the `std::shared_pointers` pointing to it).

Buffer's non owning property, from the `async_write` documentation:

> One or more buffers containing the data to be written. Although
> the buffers object may be copied as necessary, ownership of the
> underlying memory blocks is retained by the caller, which must
> guarantee that they remain valid until the handler is called.

Reference:

- http://www.boost.org/doc/libs/1_59_0/doc/html/boost_asio/reference/async_write/overload1.html
2015-09-16 02:06:58 +02:00
algorithms Fix off-by one error in decoder and make padding deterministic. 2015-09-14 23:01:38 +02:00
benchmarks change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
cmake Only replace fingerprint file when MD5 changes. Avoids rebuilding several things if nothing has actually changes, as cmake is only looking at timestamps. 2015-09-04 14:07:40 +02:00
config new cucumber profile for Jenkins that doesn't fail because of an old Gherkin bug 2014-03-24 14:29:19 +01:00
contractor Caches iterators instead of invoking function calls on every iteration. 2015-09-15 12:09:39 +02:00
data_structures Caches iterators instead of invoking function calls on every iteration. 2015-09-15 12:09:39 +02:00
descriptors tests + instructions for map matching 2015-09-11 01:34:10 +02:00
docker Remove protobuf dependencies from docker setup 2015-08-31 16:48:27 +02:00
extractor Caches iterators instead of invoking function calls on every iteration. 2015-09-15 12:09:39 +02:00
features tests + instructions for map matching 2015-09-11 01:34:10 +02:00
include/osrm Don't pass by const-value for a read-only view. 2015-09-08 23:34:20 +02:00
library fix some small issues: 2015-09-01 15:20:35 +02:00
plugins Add simplification reset that was accidentally removed 2015-09-11 01:34:10 +02:00
profiles Add switch for handling fallback name 2015-09-10 14:11:18 +02:00
routing_algorithms Fix endless loop 2015-09-03 17:02:34 +02:00
server Extend compressed output lifetime till the async write function finishes. 2015-09-16 02:06:58 +02:00
test Implement raster source feature to read data from third-party sources, to be used in lua profiles. 2015-09-03 22:28:18 -07:00
third_party Merge commit '788bc67faa7738cf7c6b2a192ecf3e3567d1c20e' into develop 2015-08-28 12:42:03 +02:00
tools rename all names with round_trip, trip or tsp to trip to standardize the naming 2015-09-01 15:20:34 +02:00
unit_tests Implement raster source feature to read data from third-party sources, to be used in lua profiles. 2015-09-03 22:28:18 -07:00
util Caches iterators instead of invoking function calls on every iteration. 2015-09-15 12:09:39 +02:00
.clang-format don't binpack parameters on 100 column width 2014-04-21 17:40:05 +02:00
.gitignore make AppVeyor green again 2015-06-18 18:16:51 +02:00
.gitmodules Removing Docs submodule 2012-12-26 18:29:16 +01:00
.travis.yml Remove protobuf dependencies from travis config 2015-08-31 16:57:42 +02:00
appveyor-build.bat AppVeyor: make tests pass again 2015-09-07 19:45:54 +02:00
appveyor.yml AppVeyor: include osrm.lib in artifact. don't stick to AppVeyor directory structure in build scripts. 2015-09-07 14:26:47 +00:00
build-local.bat AppVeyor: make tests pass again 2015-09-07 19:45:54 +02:00
CMakeLists.txt Implement raster source feature to read data from third-party sources, to be used in lua profiles. 2015-09-03 22:28:18 -07:00
datastore.cpp Remove dead code. 2015-08-20 16:15:20 +02:00
extract.cpp Move option parsing to own class 2015-05-28 15:18:48 +02:00
Gemfile change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
Gemfile.lock upgrade to cucumber 2.0 2015-04-30 18:15:46 +02:00
LICENCE.TXT change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
prepare.cpp Move option parsing to own class 2015-05-28 15:18:48 +02:00
profile.lua readding profile.lua 2013-07-02 22:51:21 +02:00
Rakefile add raketask for clearing test cache files 2014-10-17 15:13:06 +02:00
README.md Add link to documentation in the wiki 2015-05-02 15:18:13 +02:00
routed.cpp Modernize the code base to C++11 standards and beyond. 2015-08-18 12:56:34 +02:00
taginfo.json Add object_types to some tags. 2014-09-07 20:39:56 +02:00
typedefs.h Find components on edge-expanded graph 2015-08-06 11:13:25 +02:00
update_depdendencies.sh Use curl instead of http in update script. 2015-08-28 12:40:40 +02:00

About

The Open Source Routing Machine is a high performance routing engine written in C++11 designed to run on OpenStreetMap data.

Current build status

build config branch status
Linux  master Build Status
Linux  develop Build Status
Windows master/develop Build status
LUAbind fork  master Build Status

Building

For instructions on how to build and run OSRM, please consult the Wiki.

To quickly try OSRM use our free and daily updated online service

Documentation

See the Wiki's server API documentation as well as the library API documentation

References in publications

When using the code in a (scientific) publication, please cite

@inproceedings{luxen-vetter-2011,
 author = {Luxen, Dennis and Vetter, Christian},
 title = {Real-time routing with OpenStreetMap data},
 booktitle = {Proceedings of the 19th ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems},
 series = {GIS '11},
 year = {2011},
 isbn = {978-1-4503-1031-4},
 location = {Chicago, Illinois},
 pages = {513--516},
 numpages = {4},
 url = {http://doi.acm.org/10.1145/2093973.2094062},
 doi = {10.1145/2093973.2094062},
 acmid = {2094062},
 publisher = {ACM},
 address = {New York, NY, USA},
}