Fix race in advanced server examples

fix #1073
This commit is contained in:
Vinnie Falco
2018-04-12 08:54:18 -07:00
parent 3c3f4fc52b
commit f1b1ee2345
3 changed files with 28 additions and 0 deletions

View File

@ -2,6 +2,7 @@ Version 168:
* Use executor_work_guard in composed operations * Use executor_work_guard in composed operations
* Revert verb.ipp change which caused spurious warnings * Revert verb.ipp change which caused spurious warnings
* Fix race in advanced server examples
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -924,6 +924,15 @@ public:
void void
run() run()
{ {
// Make sure we run on the strand
if(! strand_.running_in_this_thread())
return boost::asio::post(
boost::asio::bind_executor(
strand_,
std::bind(
&plain_http_session::run,
shared_from_this())));
// Run the timer. The timer is operated // Run the timer. The timer is operated
// continuously, this simplifies the code. // continuously, this simplifies the code.
on_timer({}); on_timer({});
@ -996,6 +1005,15 @@ public:
void void
run() run()
{ {
// Make sure we run on the strand
if(! strand_.running_in_this_thread())
return boost::asio::post(
boost::asio::bind_executor(
strand_,
std::bind(
&ssl_http_session::run,
shared_from_this())));
// Run the timer. The timer is operated // Run the timer. The timer is operated
// continuously, this simplifies the code. // continuously, this simplifies the code.
on_timer({}); on_timer({});

View File

@ -578,6 +578,15 @@ public:
void void
run() run()
{ {
// Make sure we run on the strand
if(! strand_.running_in_this_thread())
return boost::asio::post(
boost::asio::bind_executor(
strand_,
std::bind(
&http_session::run,
shared_from_this())));
// Run the timer. The timer is operated // Run the timer. The timer is operated
// continuously, this simplifies the code. // continuously, this simplifies the code.
on_timer({}); on_timer({});