@@ -159,13 +159,13 @@ class FoxyClient : public Client,
159159
160160 void async_connect () override {
161161 boost::asio::post (
162- session_-> get_executor (),
162+ backoff_timer_. get_executor (),
163163 beast::bind_front_handler (&FoxyClient::do_run, shared_from_this ()));
164164 }
165165
166166 void async_restart (std::string const & reason) override {
167167 boost::asio::post (
168- session_-> get_executor (),
168+ backoff_timer_. get_executor (),
169169 beast::bind_front_handler (&FoxyClient::do_restart,
170170 shared_from_this (), reason));
171171 }
@@ -368,9 +368,10 @@ class FoxyClient : public Client,
368368 }
369369
370370 void async_shutdown (std::function<void ()> completion) override {
371- // Get on the session's executor, otherwise the code in the completion
372- // handler could race.
373- boost::asio::post (session_->get_executor (),
371+ // Post onto the strand to avoid races in the completion handler.
372+ // session_ can be replaced by create_session(), so use
373+ // backoff_timer_'s executor (same strand, never replaced) instead.
374+ boost::asio::post (backoff_timer_.get_executor (),
374375 beast::bind_front_handler (&FoxyClient::do_shutdown,
375376 shared_from_this (),
376377 std::move (completion)));
0 commit comments