Fix race condition in osrm-routed HTTP server

We had a similar issue a few month ago. Stumbled upon this by accident.

It goes like this:

- `output_buffer` is function-local
- we pass it to async_write and leave the scope
- `output_buffers` goes out of scope
- bad things happen, sometimes

The fix is to, again, put it inside the connection that handles itself
via the enable_shared_from_this idiom.

References:

- http://www.boost.org/doc/libs/1_59_0/doc/html/boost_asio/reference/async_write/overload1.html
- https://github.com/Project-OSRM/osrm-backend/pull/1690
This commit is contained in:
Daniel J. Hofmann
2016-01-13 18:36:11 +01:00
committed by Patrick Niklaus
parent bd91727f49
commit e7d9e42a16
2 changed files with 2 additions and 3 deletions
+2
View File
@@ -63,6 +63,8 @@ class Connection : public std::enable_shared_from_this<Connection>
http::request current_request;
http::reply current_reply;
std::vector<char> compressed_output;
// Header compression_header;
std::vector<boost::asio::const_buffer> output_buffer;
};
}
}