@@ -292,10 +292,7 @@ class FoxyClient : public Client,
292
292
// if we're shutting down, so shutting_down_ is needed to
293
293
// disambiguate.
294
294
if (shutting_down_) {
295
- session_->opts .timeout = kShutdownTimeout ;
296
-
297
- return session_->async_shutdown (beast::bind_front_handler (
298
- &FoxyClient::on_shutdown, shared_from_this (), []() {}));
295
+ return ;
299
296
}
300
297
errors_ (Error::ReadTimeout);
301
298
return async_backoff (
@@ -348,6 +345,7 @@ class FoxyClient : public Client,
348
345
std::move (completion)));
349
346
}
350
347
348
+ void on_shutdown_write () { std::cout << " shutdown write completed\n " ; }
351
349
void do_shutdown (std::function<void ()> completion) {
352
350
std::cout << " shutdown request executing..\n " ;
353
351
shutting_down_ = true ;
@@ -357,6 +355,15 @@ class FoxyClient : public Client,
357
355
} else {
358
356
session_->stream .plain ().cancel ();
359
357
}
358
+ session_->opts .timeout = kShutdownTimeout ;
359
+ session_->async_shutdown (beast::bind_front_handler (
360
+ &FoxyClient::on_shutdown, shared_from_this (),
361
+ std::move (completion)));
362
+ // Run async_write with a single null byte:
363
+ session_->stream .async_write_some (
364
+ net::buffer (" \0 " , 1 ),
365
+ beast::bind_front_handler (&FoxyClient::on_shutdown_write,
366
+ shared_from_this ()));
360
367
}
361
368
362
369
void on_shutdown (std::function<void ()> completion,
0 commit comments